Display image from DB

D

DavidC

I have an asp.net page that has an image control (named ImgSignature) inside
a Panel. When the panel is visible, I want to get the image from the database
varbinary(MAX) column and insert it into the asp Image control. I have the
following code but is not working. Can someone help? Thanks.

Using conData As SqlConnection = New
SqlConnection(DBClass.GetCoreConnectionString)
intPeopleLinkID =
Convert.ToInt32(Request.QueryString("plid"))
Const SQL As String = "SELECT [MIMEType],
[SignatureImage] FROM [ClientSignatures] WHERE [ClientID] = @ClientLinkID"
Dim myCommand As New SqlCommand(SQL, conData)
myCommand.Parameters.AddWithValue("@ClientLinkID",
intPeopleLinkID)

conData.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader

If myReader.Read Then
Response.ContentType = myReader("MIMEType").ToString()
ImgSignature.ImageUrl = myReader("SignatureImage")
End If

myReader.Close()
conData.Close()

End Using
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top