M
MattB
I'm trying to implement an example I found for displaying images stored in a
SQL database. The example code looks like this (in page_load):
Dim connstr As String = "Integrated Security=SSPI;Initial
Catalog=Northwind;Data Source=SERVER\netsdk"
Dim cnn As New SqlConnection(connstr)
Dim cmd As New SqlCommand
("select * from images where id=" & Request.QueryString("id"), cnn)
cnn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
dr.Read()
Dim bindata() As Byte = dr.GetValue(1)
Response.BinaryWrite(bindata)
I modified the connect string and query to fit my environment and ran the
page. I get that "ExecuteReader: Connection property has not been
initialized" error on this line: Dim dr As SqlDataReader =
cmd.ExecuteReader().
Can anyone tell me why or how to fix it? Thanks!
Matt
SQL database. The example code looks like this (in page_load):
Dim connstr As String = "Integrated Security=SSPI;Initial
Catalog=Northwind;Data Source=SERVER\netsdk"
Dim cnn As New SqlConnection(connstr)
Dim cmd As New SqlCommand
("select * from images where id=" & Request.QueryString("id"), cnn)
cnn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
dr.Read()
Dim bindata() As Byte = dr.GetValue(1)
Response.BinaryWrite(bindata)
I modified the connect string and query to fit my environment and ran the
page. I get that "ExecuteReader: Connection property has not been
initialized" error on this line: Dim dr As SqlDataReader =
cmd.ExecuteReader().
Can anyone tell me why or how to fix it? Thanks!
Matt