title: upload image into image actvex control from binary type in vba excel
body: <p>Currently now I'm working in VBA Excel and I'm trying to import the image (.png) from the sql server. I have completely done to insert the image into sql server in binary type. This is the sql query that i have done.</p>
  
  <p><strong><em>INSERT INTO [DemoDatabase].[dbo].[well_image] ([well_img])
  SELECT BulkColumn
  FROM openrowset ( Bulk 'C:\Users\Pictures\003.png', Single_Blob) as img</em></strong></p>
  
  <p>Then I'm try to select the fetch the image from the sql server and display it in <strong>image activex control</strong> but it give me an error.</p>
  
  <p>run time error, object required. (the error)</p>
  
  <p>Below I'm provide the code for your overview.</p>
  
  <pre><code>Set rs = New ADODB.Recordset
  Set stm = New ADODB.Stream
  
  Dim sqlquery As String
  
  sqlquery = "SELECT [well_img] FROM well_image WHERE [img_id] = 2"
  
  rs.Open sqlquery, objConnection, adOpenStatic, adLockOptimistic
  
  stm.Type = adTypeBinary
  stm.Open
  stm.Write rs("well_img").Value   'write bytes to stream
  stm.Position = 0
  
  'Sheet1.OLEObjects("well_img").Object.Picture = stm.Read 'load bytes into image control on form
   Sheet1.well_img.Picture = stm.Read    ***here is the problem
  
  stm.Close
  rs.Close
  objConnection.Close
  </code></pre>
  
  <p>when I'm debug, this line is the problem "Sheet1.well_img.Picture = stm.Read".
  I need your help. Please help me and thank u for your consideration.</p>