Hi all
I am trying to display images that are stored in the database on my web page. From what I have read, I should get the images and display them on one page, and then link my image control to the page i.e.
Photo.aspx would contain the code for downloading and displaying my image.
While the page default.aspx would have an image control imgPicture, whose imageUrl is set to the page Photo.aspx. The only problem is that I cannot get/dont know how to get the page_load event to execute.
Mike55
I am trying to display images that are stored in the database on my web page. From what I have read, I should get the images and display them on one page, and then link my image control to the page i.e.
Photo.aspx would contain the code for downloading and displaying my image.
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
OpenConnection()
sqlCmd = New SqlCommand
sqlCmd.Connection = conSql
sqlCmd.CommandText = "SELECT Picture, ImageType FROM myImages WHERE Identification = " & Request.QueryString("ID").ToString
Dim myDataReader As SqlDataReader
myDataReader = sqlCmd.ExecuteReader
Do While (myDataReader.Read())
Response.ContentType = myDataReader.Item("ImageType")
Response.BinaryWrite(myDataReader.Item("Picture"))
Loop
myDataReader.Close()
Response.Redirect("default.aspx", False)
Catch ex As Exception
Finally
CloseConnection()
End Try
End Sub
While the page default.aspx would have an image control imgPicture, whose imageUrl is set to the page Photo.aspx. The only problem is that I cannot get/dont know how to get the page_load event to execute.
Mike55