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
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
http://www.dapha.net/down/list.asp?id=1826
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q258/0/38.asp&NoWebContent=1