TO:Spring414(史无前例)
我指得是不要采取PICTUREBOX绑定到ADO数据控件的方式实现。
TO:cocoboy79(酷克.net)
谢谢,我用你提供的例程解决了问题。
我把方法公布一下,希望能对遇上类似问题的哥们姐们省点力:
Private data() As Byte, Size As Long, Diskfile As String
Private Crs As New ADODB.Recordset, Cconn As New ADODB.Connection
Public Sub MoveNext()
If Crs.EOF = True Then
Crs.MoveLast
Else
Crs.MoveNext
End If
End Sub
Public Sub MovePre()
If Crs.BOF = True Then
Crs.MoveFirst
Else
Crs.MovePrevious
End If
End Sub
Public Sub GetDataBase(MDB As String, Table As String)
Public Sub GetFrom(cfield As String, Optional Container As Variant) '从字段中得到数据放生成文件,然后再显示。
'将字段中的图形数据存入一个文件(image.bmp),然后在PICTUREBOX中显示出来
Diskfile = App.Path & "\image.bmp"
On Error Resume Next
Size = Crs(cfield).ActualSize
data() = Crs(cfield).GetChunk(Size)
Open Diskfile For Binary As #1
Put #1, , data()
Close #1
Container.Picture = LoadPicture(Diskfile)
End Sub
Public Sub PutTo(cfieldstr As String)
'将一个图形文件放入字段中
Crs.AddNew
On Error Resume Next
Diskfile = InputBox("please input a filename")
Open Diskfile For Binary As #1
Size = LOF(1)
ReDim data(Size)
Get #1, , data()
Debug.Print Diskfile & " " & Size
Crs(cfieldstr).AppendChunk data()
Crs.Update
Close #1
End Sub
Private Sub Class_Terminate()
Set Crs = Nothing
Set conn = Nothing
End Sub