Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

What am I doing wrong????? :confused:

 

 

 

Dim oSQLConn As SqlConnection = New SqlConnection()

Dim dr As SqlDataReader

oSQLConn.ConnectionString = ConnString

 

Dim strSQL As String

'Get Items..

strSQL = "SELECT object FROM images where type = 'logo2'"

oSQLConn.Open()

 

 

Dim cmd As New SqlCommand(strSQL, oSQLConn)

dr = cmd.ExecuteReader

dr.Read()

picLogo.Image = Nothing

'MsgBox(dr.Item("type"))

Dim bytImageData() As Byte = dr.Item("object")

Dim stmImageData As New MemoryStream(bytImageData)

picLogo.Image = Image.FromStream(stmImageData)

  • Administrators
Posted

Are you getting any errors when you are using the above code or is it just not displaying the image?

 

If you step through the code does bytImageData get assigned anything on the line

Dim bytImageData() As Byte = dr.Item("object")

 

Have you tried the GetSqlBytes method of the SqlDataReader? This exposes a Stream property you can use directly without needing to copy data into a bytre array etc.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...