retrieving Images Stored in the DataBase

jpselvam

New member
Joined
Jan 18, 2007
Messages
3
Programming Experience
Beginner
Help me in retrieving the image stored in the DataBase in a popup window.
thank you,
JP
 
ASP WINFORM example view images

Google on database image display asp winform

ASP page html
<IMG SRC="YourAspFile.Asp?ImageId=X">

ASP/winform pagecodebehind
Dim oConn AsNew MySqlConnection("server=YOURSERVER;user id=YOURUSER;password=YOURPASSWORD;database=YOURDB; ")
Dim oAdapter AsNew MySqlDataAdapter("SELECT image FROM image where img_id =" & TextBoxImageID, oConn)
Dim oDataSet AsNew DataSet
oConn.Open() 'optional
oAdapter.Fill(oDataSet, "TheTable")
oConn.Close() 'optional
oConn = Nothing'optional
Dim oRow As DataRow = oDataSet.Tables("image").Rows(0)
Dim vData() AsByte = CType(oRow("Data"), Byte())
With Response
.Clear
.Buffer = True
.ContentType = "Image/JPEG"
.BinaryWrite(vData)
.End()
EndWith

You can also just tell the ASP page to display an image with
Response.Redirect "/anotherimage.jpg"

For winforms
Dim vData() AsByte = CType(oRow("Data"), Byte())
Dim oStream As System.IO.MemoryStream()
oStream.Write(vData(), 0, vData.Length)
oStream.Position = 0
Me.ThePictureBox.Image = Image.FromStream(oStream)
oStream.Close
oStream = Nothing
 
Back
Top