回家了好久没有来了,现在一回学校就有问题了。
麻烦各位高手给我详细解答哦,在下谢谢了:
 图片如何加载到access数据库中及如何调用

解决方案 »

  1.   

    Access 中是 OLE 对象的字段
    Private Sub DBOpen()    'open the database with ADO    MYcon.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE=" & App.Path + "/DBpic.MDB"    MYrs.Open "PICTABLE", MYcon, 1, 3End Sub'Close the open databasePrivate Sub DBClose()    MYrs.Close    MYcon.Close    Set MYrs = Nothing    Set MYcon = NothingEnd SubPrivate Sub SaveInto(ByVal strPath As String)Dim lngFileLength   As Long   'the length of the fileDim lngBlockCount   As Long   'the number of total whole blockDim lngLastBlock   As Integer   'the length of the last blockDim lngBlockIndex   As Long   'the index of each blockDim ByteGet()   As Byte   '用于传送数据的二进制数组Dim FileNum As Integer 'return the file number which the next file will useDim strFilepath As String                strFilepath = strPath        FileNum = FreeFile()                Open strFilepath For Binary Access Read As #FileNum        lngFileLength = LOF(FileNum) '返回一个 Long,表示用 Open 语句打开的文件的大小,该大小以字节为单位。        lngBlockCount = lngFileLength \ lngBlockSize        lngLastBlock = lngFileLength Mod lngBlockSize                MYrs.AddNew            MYrs.Fields("size") = lngFileLength            MYrs.Fields("date") = Date            MYrs.Fields("name") = Trim(Text1)            ReDim ByteGet(lngBlockSize)            For lngBlockIndex = 1 To lngBlockCount                Get #FileNum, , ByteGet()                MYrs.Fields("pic").AppendChunk ByteGet()            Next            If lngLastBlock > 0 Then            ReDim ByteGet(lngLastBlock)            Get #FileNum, , ByteGet()            MYrs.Fields("pic").AppendChunk ByteGet()        End If            MYrs.Update        Close #FileNumEnd SubPrivate Sub ShowImg(ByVal RecordPoint As Long)On Error Resume NextDim temp_path As StringDim temp_file As StringDim length As LongDim lngFileLength   As Long   'the length of the fileDim lngBlockCount   As Long   'the number of total whole blockDim lngLastBlock   As Integer   'the length of the last blockDim lngBlockIndex   As Long   'the index of each blockDim ByteGet()   As Byte   '用于传送数据的二进制数组Dim FileNum As Integer 'return the file number which the next file will useDim strFileName As Stringtemp_path = Space$(MAX_PATH)length = GetTempPath(MAX_PATH, temp_path)temp_path = Left$(temp_path, length)temp_file = Space$(MAX_PATH)GetTempFileName temp_path, "per", 0, temp_filestrFileName = Left$(temp_file, InStr(temp_file, Chr$(0)) - 1)    MYrs.MoveFirst    MYrs.Move RecordPoint    Label1 = MYrs.AbsolutePosition    frmMain.Caption = MYrs.Fields("name") + Str(i)    FileNum = FreeFile()    Open strFileName For Binary As #FileNum    lngFileLength = MYrs.Fields("size")    lngBlockCount = lngFileLength \ lngBlockSize    lngLastBlock = lngFileLength Mod lngBlockSize    For lngBlockIndex = 1 To lngBlockCount        ByteGet() = MYrs.Fields("pic").GetChunk(lngBlockSize)        Put #FileNum, , ByteGet()    Next    If lngLastBlock > 0 Then    ReDim ByteGet(lngLastBlock)
            ByteGet() = MYrs.Fields("pic").GetChunk(lngBlockSize)
            Put #FileNum, , ByteGet()
        End If
        Picture1.Picture = LoadPicture(strFileName)
        Close #FileNum
        Kill strFileName
        Err.Clear
    End Sub
    Private Sub AimFilePath(ByVal strPath As String)
    Dim PathVal As String
        PathVal = Dir(strPath)
        If PathVal = Null Then MsgBox "null"
        Do While PathVal <> ""
            SaveInto (strPath + PathVal)
            PathVal = Dir
        Loop
    End Sub
      

  2.   

    去以下几个页面看看http://www.china-pub.com/computers/emook/1162/info.htmhttp://www.zjedu.org/xdjyjs/98/2082.htm
      

  3.   

    在ADO里面有一个Stream对象,可以实现对数据流的读写.
      

  4.   

    将图片写入数据库并显示
    http://www.dapha.net/down/list.asp?id=1826
      

  5.   

    下面是stream的使用祥解:
    http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q258/0/38.asp&NoWebContent=1