Monday, November 24, 2008

following source code is use Ado.stream to add image into database , but have error found, who know the answer , please help me............................

Dim CON As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim A As New ADODB.Stream

Private Sub Command1_Click()
Dim AA
Dim B
CON.ConnectionString = "driver={mysql};server=localhost;uid=root;pwd="
CON.Open
CON.Execute "use a1"
RS.CursorLocation = adUseClient
RS.Open "select * from table1", CON, adOpenForwardOnly, adLockOptimistic
Set A = New ADODB.Stream
A.Type = adTypeBinary
A.Open
A.LoadFromFile "C:\WINDOWS\Greenstone.bmp"
RS.AddNew
RS.Fields("n1") = "sss"
RS.Fields("n2").Value = A.Read
RS.Update
Set A = Nothing
Set RS = Nothing
Set CON = Nothing
End Sub

No comments: