------------------------------------------------------------------------
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim varFile() As Byte
Dim FileLength, i As Long
Dim conChunkSize As Long
' 打开文件
' read from file,save it in varFile()
Text_filename.Text = CommonDialog1.FileName
i = 0
Open Text_filename.Text For Binary As #1
FileLength = LOF(1)
If FileLength > 100000 Then
conChunkSize = FileLength / 100
Else
conChunkSize = 1000
End If
ReDim varFile(FileLength-1)
Get #1, , varFile
Close #1
MsgBox "FileLength: " & FileLength
Exit Sub
ErrHandler:
' 用户按了“取消”按钮
Exit Sub
End Sub
Private Sub Command_read_Click()
Dim SQL, ss As String
Dim varContent, varChunk22 As Variant
Dim varByte() As Byte
'从数据库中读出文件内容,写入varContent
SQL = "select * from test1 where "
ss = "id=" & Text2.Text
SQL = SQL + ss + ";"
MsgBox "SQL: " & SQL
i = 0
Do While i < FileLength
varChunk22 = rs.Fields("content2").GetChunk(conChunkSize)
varContent = varContent & varChunk22
i = i + conChunkSize
Loop
rs.Close