Hello,
I have been getting this common error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
When attempting to read from an SqlDataReader object. (Note, I am using MS Data Application Blocks)
Here is my code:
The error is occuring on the line
I haven't found any references to this problem, and I have no idea where it's breaking down. The SP works fine if I call it from the SQL Query Analyzer.
Any ideas appreciated.
Thanks,
Heather
Floyd Innovations
I have been getting this common error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
When attempting to read from an SqlDataReader object. (Note, I am using MS Data Application Blocks)
Here is my code:
Code:
Imports System.Data.SqlClient
Imports System.Data
Imports System.Text
Imports Microsoft.ApplicationBlocks.Data
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim dbCnn As SqlConnection
Dim strCnn As String
Dim strSQL As String
Dim strCurrSectionID As String
Dim iCurrentSectionID As Integer
Dim dsReader As SqlDataReader
'Database connection
strCnn = ConfigurationSettings.AppSettings("connectionstring")
dbCnn = New SqlConnection(ConfigurationSettings.AppSettings("connectionstring"))
dbCnn.Open()
'Get current SectionID
strCurrSectionID = Request.QueryString("SectionID")
iCurrentSectionID = strCurrSectionID
'Get dataset of sub-links
strSQL = "sqrySection_Selected"
dsReader = SqlHelper.ExecuteReader(strCnn, CommandType.StoredProcedure, strSQL, New SqlParameter("@SectionID", iCurrentSectionID))
While dsReader.Read()
Me.lblSectionName.Text = dsReader("SectionName")
Me.lblDescription.Text = dsReader("SecLongDescript")
End While
dsReader.Close()
dbCnn.Close()
End Sub
The error is occuring on the line
Code:
While dsReader.Read()
I haven't found any references to this problem, and I have no idea where it's breaking down. The SP works fine if I call it from the SQL Query Analyzer.
Any ideas appreciated.
Thanks,
Heather
Floyd Innovations