0

I got problem when display Picture from SQL Long BLOB to image Picture Control.

this code :

Private Sub LoadPict()
Dim SQLKoneksi As String: SQLKoneksi = "DRIVER=MySQL ODBC 5.1 DRIVER; SERVER=127.0.0.1; DATABASE=db_spp; UID=root; PWD=;"
Dim conn As ADODB.Connection: Set conn = New ADODB.Connection
conn.Open SQLKoneksi

Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset
Dim stm As ADODB.Stream: Set stm = New ADODB.Stream

Dim SQLQuery As String: SQLQuery = "SELECT foto_petugas FROM petugas WHERE id_petugas='PTG001'"
rs.Open SQLQuery, conn, adOpenStatic, adLockReadOnly

stm.Type = adTypeBinary
stm.Open
stm.Write rs("foto_petugas").Value
stm.Position = 0
Me.Gambar.Picture = stm.Read
stm.Close: rs.Close: conn.Close
Set stm = Nothing: Set rs = Nothing: Set conn = Nothing
End sub

I get message error is "Object Required" in this line :

Me.Gambar.Picture = stm.Read

How to Solve it? thanks

Cœur
  • 37,241
  • 25
  • 195
  • 267

0 Answers0