S
sean
Hi There,
I am trying to display some images from SQL Server, the image is displaying
correctly, but when I have more than one row in the table I only get one
image displayed? What am I doing wrong? is there a better way to do this?
Sean - thanks in advance
<%@ Page Language="vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<HTML>
<HEAD>
<title>Retrieving Image from the Sql Server</title>
<script runat=server>
Public Sub Page_Load(sender As Object, e As
EventArgs)
Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As New SqlCommand("Select
ListingImage,ListingImageType from tblListings", myConnection)
Try
myConnection.Open()
Dim myDataReader as
SqlDataReader
myDataReader =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Do While
(myDataReader.Read())
'Dim bindata() As
Byte = myDataReader.Item("ListingImage")
'Response.BinaryWrite(bindata)
Response.BinaryWrite(myDataReader.Item("ListingImage"))
'Response.BinaryWrite(myDataReader.Item("ListingImageType"))
Loop
myConnection.Close()
Response.Write("image
displayed")
Catch SQLexc As SqlException
Response.Write("Read Failed
: " & SQLexc.ToString())
End Try
End Sub
</script>
</HEAD>
<body style="font: 10pt verdana">
</body>
</HTML>
I am trying to display some images from SQL Server, the image is displaying
correctly, but when I have more than one row in the table I only get one
image displayed? What am I doing wrong? is there a better way to do this?
Sean - thanks in advance
<%@ Page Language="vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<HTML>
<HEAD>
<title>Retrieving Image from the Sql Server</title>
<script runat=server>
Public Sub Page_Load(sender As Object, e As
EventArgs)
Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As New SqlCommand("Select
ListingImage,ListingImageType from tblListings", myConnection)
Try
myConnection.Open()
Dim myDataReader as
SqlDataReader
myDataReader =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Do While
(myDataReader.Read())
'Dim bindata() As
Byte = myDataReader.Item("ListingImage")
'Response.BinaryWrite(bindata)
Response.BinaryWrite(myDataReader.Item("ListingImage"))
'Response.BinaryWrite(myDataReader.Item("ListingImageType"))
Loop
myConnection.Close()
Response.Write("image
displayed")
Catch SQLexc As SqlException
Response.Write("Read Failed
: " & SQLexc.ToString())
End Try
End Sub
</script>
</HEAD>
<body style="font: 10pt verdana">
</body>
</HTML>