image from sql to datagrid !!! HELP"" HELP

  • Thread starter Thread starter Michael Persaud
  • Start date Start date
M

Michael Persaud

hi all

pls help me here. I am trying to retrieve images from a sql srv and want to
populate a datagrid with the image or a picture box equivalent. after
running the sqlcmd it may return many pics and i need them to be listed in
as pic inwhatever format. The image is stored as image type.

i click a button which calls the following

Private Sub DoLoadImage()
Dim SubCatID As String
SubCatID = SubCategoryList.SelectedItem.Value.ToString()

Dim stringSql As String = "select imid,Images,Description from
AllData where SCId=" + SubCatID
Label1.Text = stringSql

Dim cmd As New SqlClient.SqlCommand(stringSql, DisplayCon)
DisplayCon.Open()

Dim ds As New DataSet
AllDataDA.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()

DisplayCon.Close()

End Sub


I get the grid with all the other data except the "BLOB".

PLS HELP

THanks
MP
 
What you need to do (Or at least this is one way of doing it) is write the
file from the DB into a new file, like "c:\inetpub\your directory\jpg\" &
session.sessionID & ".jpg", and then serve that jpg in the table or image
(image.imageurl = http://whatever/jpg/ & session.sessionid & ".jpg")

The BLOB can be any binary data and I don't think the server can determine
on-the-fly that the binary data just so happens to be a servable picture
file.

HTH,

Steve
 
If I understand what you want to do correctly, another possibility is
to create a reference in your datagrid to a URL which will extract
your BLOB file from the database and write it to the Response stream.

The URL in the datagrid will look something like
"/MyImage.aspx?id=1234", and in MyImage.aspx, you'll set the
ContentType to something like "image/jpeg" and write out the bytes
from your BLOB.

-Mike
 
Back
Top