各位大虾,我现在有20张图片名称为0-19.bmp,我想通过一个按键来把它们一次性导入到ACCESS数据库,数据库名为image.mdb 表名为pic 表第一列为自动编号,第二列名称为image,如果表里没有数据则自动添加,有数据则覆盖,下面是我做的单个数据更改,如何批量更改就有点困难。
Dim PictBmp As String
Dim ByteData() As Byte
Dim SourceFile As Integer
' cmdlFilePath.Filter = "(*.bmp;*.ico;*.jpg)|*.bmp;*.ico;*.jpg"
' cmdlFilePath.ShowOpen
' If cmdlFilePath.FileName <> "" Then
If text1.Text = "" Then
MsgBox "请选择一个图片!", vbCritical, "数据检查"
Else
PictBmp = text1.Text
SourceFile = FreeFile
Open PictBmp For Binary Access Read As SourceFile
lngLengh = LOF(SourceFile)
Debug.Print "lngLengh is " & lngLengh
If lngLengh = 0 Then
Close SourceFile
MsgBox PictBmp & " empty or not found."
Exit Sub
Else
intChunks = lngLengh / ChunkSize
intFragment = lngLengh Mod ChunkSize ReDim ByteData(intFragment)
Get SourceFile, , ByteData()
RS(1).AppendChunk ByteData() ReDim ByteData(ChunkSize)
For i = 1 To intChunks
Get SourceFile, , ByteData()
RS(1).AppendChunk ByteData()
Next i
RS.Update
Close SourceFile
End If ShowPic
请高手指教如何在此基础上做修改,谢谢!
Dim PictBmp As String
Dim ByteData() As Byte
Dim SourceFile As Integer
' cmdlFilePath.Filter = "(*.bmp;*.ico;*.jpg)|*.bmp;*.ico;*.jpg"
' cmdlFilePath.ShowOpen
' If cmdlFilePath.FileName <> "" Then
If text1.Text = "" Then
MsgBox "请选择一个图片!", vbCritical, "数据检查"
Else
PictBmp = text1.Text
SourceFile = FreeFile
Open PictBmp For Binary Access Read As SourceFile
lngLengh = LOF(SourceFile)
Debug.Print "lngLengh is " & lngLengh
If lngLengh = 0 Then
Close SourceFile
MsgBox PictBmp & " empty or not found."
Exit Sub
Else
intChunks = lngLengh / ChunkSize
intFragment = lngLengh Mod ChunkSize ReDim ByteData(intFragment)
Get SourceFile, , ByteData()
RS(1).AppendChunk ByteData() ReDim ByteData(ChunkSize)
For i = 1 To intChunks
Get SourceFile, , ByteData()
RS(1).AppendChunk ByteData()
Next i
RS.Update
Close SourceFile
End If ShowPic
请高手指教如何在此基础上做修改,谢谢!
http://download.csdn.net/detail/veron_04/1467817