Let me just preface this post with the statement that I'm fairly new to .NET.
I want to create a Master/Detail page. I've got the Master page working fine: it contains a list of records each having a clickable ID field that passes that ID value to the Detail page.
I want to display the data corresponding to the ID that was passed on my second page. I know how to do it using a Stored Procedure, but I don't know how to do it without using one.
Here's what I have so far in my Page_Load sub:
'Get the value of the URL variable that was passed
Dim intID as Integer = CInt(Request.Params("ID))
Dim strSQL as String = "select o.orderid, o.cycle, o.orderingUIC, o.shippingUIC, o.answersheets, e.quantity, e.rate from ordertblx o, examsx e where (o.orderid = e.orderid) and o.orderid =" & intID
Dim myConn as SqlConnection = New SQLConnection(ConfigurationSettings.AppSettings("ConnectionString"
)
myConn.Open()
Dim myComm as SqlCommand = New SqlCommand(strSQL, myConn)
Dim myDR as SqlDataReader = myComm.ExecuteReader(CommandBehavior.CloseConnection)
Here's where my problem is:
There will only be one record returned and all I want to do is set certain labels to the fields in the record returned.
I read in a book to do something like this:
lblCycle.Text = myDR.Item("cycle"
lblOrderingUIC.Text = myDR.Item("orderingUIC"
But that didn't work - I got a message saying that "Invalid attepmpt to read when no data is present."
Any help/suggestions would be greatly appreciated.
Thanks in advance,
Suzanne
I want to create a Master/Detail page. I've got the Master page working fine: it contains a list of records each having a clickable ID field that passes that ID value to the Detail page.
I want to display the data corresponding to the ID that was passed on my second page. I know how to do it using a Stored Procedure, but I don't know how to do it without using one.
Here's what I have so far in my Page_Load sub:
'Get the value of the URL variable that was passed
Dim intID as Integer = CInt(Request.Params("ID))
Dim strSQL as String = "select o.orderid, o.cycle, o.orderingUIC, o.shippingUIC, o.answersheets, e.quantity, e.rate from ordertblx o, examsx e where (o.orderid = e.orderid) and o.orderid =" & intID
Dim myConn as SqlConnection = New SQLConnection(ConfigurationSettings.AppSettings("ConnectionString"
myConn.Open()
Dim myComm as SqlCommand = New SqlCommand(strSQL, myConn)
Dim myDR as SqlDataReader = myComm.ExecuteReader(CommandBehavior.CloseConnection)
Here's where my problem is:
There will only be one record returned and all I want to do is set certain labels to the fields in the record returned.
I read in a book to do something like this:
lblCycle.Text = myDR.Item("cycle"
lblOrderingUIC.Text = myDR.Item("orderingUIC"
But that didn't work - I got a message saying that "Invalid attepmpt to read when no data is present."
Any help/suggestions would be greatly appreciated.
Thanks in advance,
Suzanne