1个回答
展开全部
Dim con As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim ChunkSize As Long, Chunks As Long, Chunk() As Byte
Dim i As Integer, j As Integer, MediaTemp As String
ChunkSize = 10000
For i = 1 To List1.ListCount - 1
If Len(Dir(dbPath + "img\" + List1.List(i), vbDirectory)) = 0 Then MkDir (dbPath + "img\" + List1.List(i))
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath + List1.List(i) + ".mdb;Persist Security Info=False"
con.Open
RS.Source = "select * from [Images] order by ID"
RS.ActiveConnection = con
RS.Open
If RS.EOF Then
RS.Close
Exit Sub
End If
Do While Not RS.EOF
'第二步,读出长二进制数据即图片数据,把它转换成图片文件,操作过程如下
MediaTemp = dbPath + "img\" + List1.List(i) + "\" + RS.Fields
DataFile = 1
Open MediaTemp For Binary Access Write As DataFile
lngTotalSize = RS!PIC.ActualSize
Chunks = lngTotalSize / ChunkSize
Fragment = lngTotalSize Mod ChunkSize
ReDim Chunk(Fragment)
Chunk() = RS!PIC.GetChunk(Fragment)
Put DataFile, , Chunk()
For j = 1 To Chunks
ReDim Chunk(ChunkSize)
Chunk() = RS!PIC.GetChunk(ChunkSize)
Put DataFile, , Chunk()
Next j
Close DataFile
RS.MoveNext
Loop
'第三步,关闭数据库,这样就可以显示所要的图片了。
RS.Close
con.Close
Next i
MsgBox "OK!"
Dim RS As New ADODB.Recordset
Dim ChunkSize As Long, Chunks As Long, Chunk() As Byte
Dim i As Integer, j As Integer, MediaTemp As String
ChunkSize = 10000
For i = 1 To List1.ListCount - 1
If Len(Dir(dbPath + "img\" + List1.List(i), vbDirectory)) = 0 Then MkDir (dbPath + "img\" + List1.List(i))
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath + List1.List(i) + ".mdb;Persist Security Info=False"
con.Open
RS.Source = "select * from [Images] order by ID"
RS.ActiveConnection = con
RS.Open
If RS.EOF Then
RS.Close
Exit Sub
End If
Do While Not RS.EOF
'第二步,读出长二进制数据即图片数据,把它转换成图片文件,操作过程如下
MediaTemp = dbPath + "img\" + List1.List(i) + "\" + RS.Fields
DataFile = 1
Open MediaTemp For Binary Access Write As DataFile
lngTotalSize = RS!PIC.ActualSize
Chunks = lngTotalSize / ChunkSize
Fragment = lngTotalSize Mod ChunkSize
ReDim Chunk(Fragment)
Chunk() = RS!PIC.GetChunk(Fragment)
Put DataFile, , Chunk()
For j = 1 To Chunks
ReDim Chunk(ChunkSize)
Chunk() = RS!PIC.GetChunk(ChunkSize)
Put DataFile, , Chunk()
Next j
Close DataFile
RS.MoveNext
Loop
'第三步,关闭数据库,这样就可以显示所要的图片了。
RS.Close
con.Close
Next i
MsgBox "OK!"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询