'读取图形文件
Public Sub ColumnToFile(Col As ADODB.Field, ByVal DiskFile As String, BlockSize As Long, ColSize As Long)
Dim NumBlocks As Integer
Dim LeftOver As Long
Dim byteData() As Byte '字节数组
Dim DestFile As Integer, i As Integer
' 如果文件已经存在,则删除
If Len(Dir$(DiskFile)) > 0 Then
Kill DiskFile
End If
DestFile = FreeFile
Open DiskFile For Binary As DestFile
NumBlocks = ColSize \ BlockSize
LeftOver = ColSize Mod BlockSize
If Col.Type = adLongVarBinary Then
If LeftOver > 0 Then
ReDim byteData(LeftOver)
byteData() = Col.GetChunk(LeftOver)
Put DestFile, , byteData()
End If
ReDim byteData(BlockSize)
For i = 1 To NumBlocks
byteData() = Col.GetChunk(BlockSize)
Put DestFile, , byteData()
Next
End If
Close DestFile
End Sub'存放图形文件
Public Sub FileToColumn(Col As ADODB.Field, DiskFile As String, BlockSize As Long)
Dim byteData() As Byte '字节数组
Dim NumBlocks As Integer
Dim fileLength As Long
Dim LeftOver As Long
Dim SourceFile As Integer
Dim i As Integer
SourceFile = FreeFile
Open DiskFile For Binary As SourceFile
fileLength = LOF(SourceFile) '获得文件长度
If fileLength = 0 Then
Close SourceFile
MsgBox DiskFile & "没有找到."
Else
NumBlocks = fileLength \ BlockSize
LeftOver = fileLength Mod BlockSize
If Col.Type = adLongVarBinary Then
If LeftOver > 0 Then
ReDim byteData(LeftOver)
Get SourceFile, , byteData()
Col.AppendChunk byteData()
End If
ReDim byteData(BlockSize)
For i = 1 To NumBlocks
Get SourceFile, , byteData()
Col.AppendChunk byteData()
Next i
Close SourceFile
End If
End If
End Sub示例:f_cDial.FileToColumn rs.Fields!声音, f_cDial.AuTapeFilePath, 102400
f_cDial.AuTapeFilePath为图象或声音文件(含路径)
Public Sub ColumnToFile(Col As ADODB.Field, ByVal DiskFile As String, BlockSize As Long, ColSize As Long)
Dim NumBlocks As Integer
Dim LeftOver As Long
Dim byteData() As Byte '字节数组
Dim DestFile As Integer, i As Integer
' 如果文件已经存在,则删除
If Len(Dir$(DiskFile)) > 0 Then
Kill DiskFile
End If
DestFile = FreeFile
Open DiskFile For Binary As DestFile
NumBlocks = ColSize \ BlockSize
LeftOver = ColSize Mod BlockSize
If Col.Type = adLongVarBinary Then
If LeftOver > 0 Then
ReDim byteData(LeftOver)
byteData() = Col.GetChunk(LeftOver)
Put DestFile, , byteData()
End If
ReDim byteData(BlockSize)
For i = 1 To NumBlocks
byteData() = Col.GetChunk(BlockSize)
Put DestFile, , byteData()
Next
End If
Close DestFile
End Sub'存放图形文件
Public Sub FileToColumn(Col As ADODB.Field, DiskFile As String, BlockSize As Long)
Dim byteData() As Byte '字节数组
Dim NumBlocks As Integer
Dim fileLength As Long
Dim LeftOver As Long
Dim SourceFile As Integer
Dim i As Integer
SourceFile = FreeFile
Open DiskFile For Binary As SourceFile
fileLength = LOF(SourceFile) '获得文件长度
If fileLength = 0 Then
Close SourceFile
MsgBox DiskFile & "没有找到."
Else
NumBlocks = fileLength \ BlockSize
LeftOver = fileLength Mod BlockSize
If Col.Type = adLongVarBinary Then
If LeftOver > 0 Then
ReDim byteData(LeftOver)
Get SourceFile, , byteData()
Col.AppendChunk byteData()
End If
ReDim byteData(BlockSize)
For i = 1 To NumBlocks
Get SourceFile, , byteData()
Col.AppendChunk byteData()
Next i
Close SourceFile
End If
End If
End Sub示例:f_cDial.FileToColumn rs.Fields!声音, f_cDial.AuTapeFilePath, 102400
f_cDial.AuTapeFilePath为图象或声音文件(含路径)
然后Image1.Picture=LoadPicture("FileName")