B
Blasting Cap
I am using the following code to pull an image out of a database &
display it on a web page.
Dim data As New data
Dim sID As String = Request.Params("itemID")
Dim sqlConnection As New SqlConnection(data.connectionString)
Dim sqlCom As New SqlCommand("Select Data, Type From tblImageStorage
Where (Story_ID='" & sID & "')", sqlConnection)
Dim sqlDataReader As SqlDataReader
sqlConnection.Open()
sqlDataReader = sqlCom.ExecuteReader
sqlDataReader.Read()
Dim byteArray As Byte() = CType(sqlDataReader("Data"), Byte())
Dim mstream As System.IO.MemoryStream = New
System.IO.MemoryStream(byteArray, 0, byteArray.Length)
Dim dbImage As System.Drawing.Image =
System.Drawing.Image.FromStream(New System.IO.MemoryStream(byteArray))
Dim bmp As Bitmap = New Bitmap(dbImage)
Dim scale As Single = 300.0F / System.Math.Max(0, bmp.Width)
Dim thumbnailImage As System.Drawing.Image =
bmp.GetThumbnailImage(CType((bmp.Width * scale), Integer),
CType((bmp.Height * scale), Integer), Nothing, System.IntPtr.Zero)
thumbnailImage.Save(Context.Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
sqlConnection.Close()
It works fine & displays the image fine.
However, the application I have needs to have the ability to read a
story out of the same sql database & display it. It seems that I can
only do one thing.
How can you display the graphic read from a SQL database AND the story
associated with it on the same page?
As an added "oddity" I have noticed that on the rendered page, that
"View Source" is not available from the file/edit/view menu. Do not
know if that means anything or not.
Any help appreciated.
BC
display it on a web page.
Dim data As New data
Dim sID As String = Request.Params("itemID")
Dim sqlConnection As New SqlConnection(data.connectionString)
Dim sqlCom As New SqlCommand("Select Data, Type From tblImageStorage
Where (Story_ID='" & sID & "')", sqlConnection)
Dim sqlDataReader As SqlDataReader
sqlConnection.Open()
sqlDataReader = sqlCom.ExecuteReader
sqlDataReader.Read()
Dim byteArray As Byte() = CType(sqlDataReader("Data"), Byte())
Dim mstream As System.IO.MemoryStream = New
System.IO.MemoryStream(byteArray, 0, byteArray.Length)
Dim dbImage As System.Drawing.Image =
System.Drawing.Image.FromStream(New System.IO.MemoryStream(byteArray))
Dim bmp As Bitmap = New Bitmap(dbImage)
Dim scale As Single = 300.0F / System.Math.Max(0, bmp.Width)
Dim thumbnailImage As System.Drawing.Image =
bmp.GetThumbnailImage(CType((bmp.Width * scale), Integer),
CType((bmp.Height * scale), Integer), Nothing, System.IntPtr.Zero)
thumbnailImage.Save(Context.Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
sqlConnection.Close()
It works fine & displays the image fine.
However, the application I have needs to have the ability to read a
story out of the same sql database & display it. It seems that I can
only do one thing.
How can you display the graphic read from a SQL database AND the story
associated with it on the same page?
As an added "oddity" I have noticed that on the rendered page, that
"View Source" is not available from the file/edit/view menu. Do not
know if that means anything or not.
Any help appreciated.
BC