请看下面的代码有什么问题?
Image1.Picture = Nothing
If rec("照片").ActualSize > 50 Then
bit1 = rec.Fields("照片").GetChunk(rec("照片").ActualSize)
'然后将字节数组的内容拼装成文件即可
Open "c:\1.bmp" For Binary As #1
Put 1, 1, bit1
Close 1
Image1.Picture = LoadPicture("c:\1.bmp")
Image1.Stretch = True
' Picture1.Picture = LoadPicture("c:\1.bmp")
Kill ("c:\1.bmp")
End If
执行到Image1.Picture = LoadPicture("c:\1.bmp")时,系统报错“无效图片”,请大家帮忙,
Image1.Picture = Nothing
If rec("照片").ActualSize > 50 Then
bit1 = rec.Fields("照片").GetChunk(rec("照片").ActualSize)
'然后将字节数组的内容拼装成文件即可
Open "c:\1.bmp" For Binary As #1
Put 1, 1, bit1
Close 1
Image1.Picture = LoadPicture("c:\1.bmp")
Image1.Stretch = True
' Picture1.Picture = LoadPicture("c:\1.bmp")
Kill ("c:\1.bmp")
End If
执行到Image1.Picture = LoadPicture("c:\1.bmp")时,系统报错“无效图片”,请大家帮忙,
Picture1.DataField = "照片" 'rec("照片").name
Open "c:\015.JPG" For Binary Access Read As lngDataFile
lngLengh = LOF(lngDataFile)
If lngLengh = 0 Then Close lngDataFile: Exit Sub
intChunks = lngLengh \ ChunkSize
intFragment = lngLengh Mod ChunkSize
'OpenData 打开数据库
Dim i As Integer
Dim rs As New ADODB.Recordset
Dim strQ As String
If rs.State = adStateOpen Then rs.Close
strQ = "select * from scanimage"
rs.Open strQ, localcon1, adOpenStatic, adLockOptimistic
' Set rs = localcon1.Execute("select * from scanimage where id=1", adOpenKeyset, adLockOptimistic)' On Error Resume Next
rs.AddNew
ReDim Chunk(intFragment)
Get lngDataFile, , Chunk()
rs.Fields("imagename").AppendChunk Chunk()
ReDim Chunk(ChunkSize)
For i = 1 To intChunks
Get lngDataFile, , Chunk()
rs.Fields("imagename").AppendChunk Chunk()
Next i
rs.Update
rs.Close
Close lngDataFile
哪里有问题?
Private Sub ImportBLOB(cn As ADODB.Connection)
Dim rs As New ADODB.Recordset
Dim stm As ADODB.Stream
Set stm = New ADODB.Stream
' Skip any table not found errors
On Error Resume Next
cn.Execute "drop table BinaryObject"
On Error GoTo 0
'Create the BinaryObject table
cn.Execute "create table BinaryObject " & _
"(blob_id int IDENTITY(1,1), " & _
"blob_filename varchar(256), " & _
"blob_object image)"
rs.Open "Select * from BinaryObject where 1=2", cn, adOpenKeyset, adLockOptimistic
'Read the binary files from disk
stm.Type = adTypeBinary
stm.Open
stm.LoadFromFile App.Path & "\BLOBsample.jpg"
rs.AddNew
rs!blob_filename = App.Path & "\BLOBsample.jpg"
rs!blob_object = stm.Read
'Insert the binary object in the table
rs.Update
rs.Close
stm.Close
Set rs = Nothing
Set stm = Nothing
End Sub
Private Sub DisplayBLOB(cn As ADODB.Connection) Dim rs As New ADODB.Recordset
' Select the only image in the table
rs.Open "Select * from BinaryObject where blob_id = 1", cn
' Set the DataSource to the recordset
Set imgBinaryData.DataSource = rs
'Set the DataField to the BLOB field
imgBinaryData.DataField = rs!blob_object.Name
'Release the recordset
rs.Close
Set rs = NothingEnd Sub
bit1() = rs("照片")
Open "1.bmp" For Binary As #1
Put 1, , bb()
Close 1
Image1.Picture = LoadPicture("1.bmp")
Kill "t2.bmp"
http://www.dapha.net/down/list.asp?id=1826
http://www.dapha.net/down/list.asp?id=1826