加一个表Picture
ID  autonumber
Picture ole object(access)

解决方案 »

  1.   

    可以保存在数据库里的
    Public Function AddPicture(ByVal sID As String, ByRef abPic() As Byte) As Integer
        Dim oRS As New ADODB.Recordset
        Dim sSQL As String    
        sSQL = "SELECT ID,Picture FROM " & gcsTablePicture
        With oRS
            .Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
            .AddNew
            .Fields("ID") = sID
            .Fields("Picture").AppendChunk abPic
            .Update
        End With
        Set oRS = Nothing
    End FunctionPublic Function DeletePicture(ByVal sID As String) As Boolean
        Dim sSQL As String    
        sSQL = "DELETE FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
        DeletePicture = ExecuteSQL(sSQL)
    End Function
    Public Function GetPicture(ByRef sID As String) As Byte()
        Dim sSQL As String
        Dim oRS As New ADODB.Recordset
        Dim abPic() As Byte
        Dim lPicSize As Long
        
        sSQL = "SELECT ID,Picture FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
        With oRS
            .Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
            lPicSize = .Fields("Picture").ActualSize - 1
            If lPicSize < 0 Then GoTo EndRow
            GetPicture = .Fields("Picture").GetChunk(lPicSize)
        End With
    EndRow:
        Set oRS = Nothing
    End Function
      

  2.   

    回复人: nik_Amis(Azrael) ( ) 信誉:105  2003-01-17 13:00:00  得分:0 
     
     
      加一个表Picture
    ID  autonumber
    Picture ole object(access)
                       ^^^^^^^
     
      

  3.   

    给你段程序,我前不久刚做的,调用参数为姓名,序号,要显示图片的字段名,以及表名。
    要显示多幅,连续调用即可
    Function showpicture(outtb As String, name As String, number As String, filefield As String) 'As BooleanDim outrs As New ADODB.Recordset
    Dim picstream As ADODB.Stream
    Dim constr As String
    Dim outconn As New ADODB.Connectionoutconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\.mdb;Persist Security Info=False"
    outconn.Open
    Set picstream = New ADODB.Stream
            
    picstream.Mode = adModeReadWrite
    picstream.Type = adTypeBinary
    picstream.Open
    Set outrs = New ADODB.Recordset
    outrs.Source = "select" + " " + filefield + " " + "from" + " " + outtb + " " + " where 姓名=" + "'" + name + "'" + " and 序号=" + numberSet outrs.ActiveConnection = outconnoutrs.LockType = adLockOptimistic
    outrs.CursorType = adOpenKeyset
    outrs.OpenDim msgstring As StringIf outrs.Fields(filefield).ActualSize <> 0 Then
        picstream.Write (outrs.Fields(filefield).Value)
        picstream.SaveToFile "c:\aa.tmp", adSaveCreateOverWrite
        Picture1.Picture = LoadPicture("c:\aa.tmp")
        '******************************************
        'Picture1.Picture = LoadPicture(filename)
        If Picture1.Picture = 0 Then
        
        Exit Function
        End If
            
    Else
        'msgstring = filefield + "没有记录"
        'MsgBox msgstring, vbOKOnly, "没有记录"
        Picfinal.Picture = LoadPicture("")
       'showpicture = False
    End Ifoutrs.Close
    picstream.Close
    outconn.CloseEnd Function
      

  4.   

    算你运气,我刚研究出来,你给我发邮件吧,[email protected]
      

  5.   

    用数据库:
    Public Function AddPicture(ByVal sID As String, ByRef abPic() As Byte) As Integer
        Dim oRS As New ADODB.Recordset
        Dim sSQL As String    
        sSQL = "SELECT ID,Picture FROM " & gcsTablePicture
        With oRS
            .Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
            .AddNew
            .Fields("ID") = sID
            .Fields("Picture").AppendChunk abPic
            .Update
        End With
        Set oRS = Nothing
    End FunctionPublic Function DeletePicture(ByVal sID As String) As Boolean
        Dim sSQL As String    
        sSQL = "DELETE FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
        DeletePicture = ExecuteSQL(sSQL)
    End Function
    Public Function GetPicture(ByRef sID As String) As Byte()
        Dim sSQL As String
        Dim oRS As New ADODB.Recordset
        Dim abPic() As Byte
        Dim lPicSize As Long
        
        sSQL = "SELECT ID,Picture FROM " & gcsTablePicture & " WHERE ID='" & sID & "'"
        With oRS
            .Open sSQL, gsConnectionString, adOpenStatic, adLockOptimistic
            lPicSize = .Fields("Picture").ActualSize - 1
            If lPicSize < 0 Then GoTo EndRow
            GetPicture = .Fields("Picture").GetChunk(lPicSize)
        End With
    EndRow:
        Set oRS = Nothing
    End Function