VERSION 5.00 Begin VB.Form TONCISQLBLOB Caption = "Form1" ClientHeight = 1365 ClientLeft = 60 ClientTop = 405 ClientWidth = 8445 LinkTopic = "Form1" ScaleHeight = 1365 ScaleWidth = 8445 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdStart Caption = "Start" Height = 495 Left = 3360 TabIndex = 0 Top = 480 Width = 1455 End End Attribute VB_Name = "TONCISQLBLOB" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit '--------------- Additional Project References ---------------------------------------------------- 'OLE Automation 'Microsoft ActixeX Data Objects 2.8 Library 'ODBC Driver & DataSource Name Functions '----------------- ODBC Driver Installed------------------------------------------------------ 'MySQL ODBC 3.51 Driver Version 3.51 12 00 '--------------------------------------------------------------------------------------- '--------------- MySQL Database -------------------------------------------------------- 'CREATE TABLE `mysqlblob`.`bug27117` ( ' `ndx` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, ' `picname` VARCHAR(45), ' `picture` BLOB, ' PRIMARY KEY (`index`) ') 'ENGINE = InnoDB 'CHARACTER SET latin1 COLLATE latin1_german1_ci; '----------------------------------------------------------------------------------------- 'ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=mysqlblob;UID=root;PWD=xenia;OPTION=16427" Private Sub cmdStart_Click() Dim I 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=mysqlblob;UID=root;PWD=xenia;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 = adUseClient rs.Properties("Update Criteria").Value = 0 'adCriteriaKey '----------------- Cursor ForwardOnly -------------------------------------- rs.Open "Select * from bug27117 Where picname='pic" & CStr(I) & "'", cx, adOpenForwardOnly, adLockOptimistic '---------------- You can also use this code ------------------------------ 'rs.Open "Select * from bug27117 Where picname='pic" & CStr(I) & "'", cx, adOpenStatic, adLockOptimistic '--------------------------------------------------------------------------- Set stm = New ADODB.Stream stm.Type = StreamTypeEnum.adTypeBinary stm.Open stm.LoadFromFile (App.Path & "\testpicture.jpg") rs.Fields("picture").Value = stm.Read rs.Update stm.Close Set stm = Nothing rs.Close Next I Set rs = Nothing End Sub