Private Sub bnBug28891_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnBug28891.Click Dim I As Long, J As Long Dim cx As New ADODB.Connection Dim rs As New ADODB.Recordset Dim stm As ADODB.Stream cx.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=test;UID=root;PWD=****;OPTION=16427" cx.Open() '------------------ create table ------------------------------ cx.Execute("DROP TABLE IF EXISTS bug27117") cx.Execute("CREATE TABLE bug27117(ndx BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,picname VARCHAR(45),picture BLOB)") '-------------------------------------------------------------- For I = 1 To 10 '---------------- create record -------------------------------------------- cx.Execute("INSERT INTO bug27117 (picname) VALUES ('pic" & CStr(I) & "')") '----------------- These are the key lines of code ------------------------- rs.CursorLocation = CursorLocationEnum.adUseClient rs.Properties("Update Criteria").Value = 0 'adCriteriaKey '----------------- Cursor ForwardOnly -------------------------------------- rs.Open("Select * from bug27117 Where picname='pic" & CStr(I) & "'", cx, CursorTypeEnum.adOpenForwardOnly, LockTypeEnum.adLockOptimistic) stm = New ADODB.Stream stm.Type = StreamTypeEnum.adTypeBinary stm.Open() stm.LoadFromFile(Application.StartupPath & "\testpicture.jpg") rs.Fields("picture").Value = stm.Read rs.Update() stm.Close() stm = Nothing rs.Close() Next I J = MsgBox("Do you wish to retreive picture(s)?", vbYesNo + vbQuestion, "Picture(s) stored in Database") If J = vbNo Then Exit Sub For I = 1 To 10 rs.Open("Select * from bug27117 Where picname='pic" & CStr(I) & "'", cx, CursorTypeEnum.adOpenForwardOnly, LockTypeEnum.adLockOptimistic) If Not rs.EOF Then <<< Unnecessary If Not IsDBNull(rs.Fields(2).Value) Then stm = New ADODB.Stream stm.Type = StreamTypeEnum.adTypeBinary stm.Open() stm.Write(rs.Fields("picture").Value) stm.SaveToFile(Application.StartupPath & "\picture" & CStr(I) & "-tst.jpg", SaveOptionsEnum.adSaveCreateOverWrite) End If '---------------------------------------------------------------------------------------------------------- 'rs.MoveNext() <<< Unnecessary End If rs.Close() 'J = MsgBox("Do you wish to retrieve next?", vbYesNo + vbQuestion, "Retrieving Pictures from Database") 'If J = vbNo Then Exit Sub Next I rs = Nothing End Sub