I have entered an image in sql server database successfully. Now i want to retrieve this image from database and show it in an Image control. I don’t want to put any ListBoxes on the page. I wrote in ASP dot Net..
Dim MS As MemoryStream
Dim IMG As System.Drawing.Image
Dim FS As FileStream
Dim FI As FileInfo
Dim IMGSTRM As Stream
Dim IMGBYTS As Byte()
Dim ImgData() As Byte
CMD1 = New SqlCommand("select * from IMG where userid=0", CON1)
If Not IsNothing(RDR1) Then RDR1.Close()
RDR1 = CMD1.ExecuteReader()
If RDR1.Read Then
IMGBYTS = RDR1!img
MS = New MemoryStream(IMGBYTS, False)
IMG = Image.FromStream(MS)
PIC1.ImageUrl = IMG
End If
The problem is in the bold 2 lines above End If
if you are using the desktop application this is the solution
Private Sub SqlBlob2File(ByVal DestFilePath As String)
this is the link where you may want to look at : http://support.microsoft.com/kb/321900/en-us
asp.net solution
in case of web page or aspx page you can only show an image on a webpage from an Url, there is first should be a picture webpage as webform2 with only a picture box should have to be there. This page is the image for the webform1.
In this way you can put as much pictures on a page as you want, depending of
course that you make the same amount of pseudo pages (and don’t give them
the same name).
I hope it will be a nice pages.
\\
There has to be an imagebox, a button and a label on the webform1
///
\\
///