I'm trying to pass a sqlDataReader from a called function to a calling
function but got nothing back and a message saying "An unhandled
exception of type 'System.NullRef erenceException ' occurred in
Throw.exe. Object reference not set to an instance of an object."
Here is my code:
Public Function testint() As String
'Nothing returns here, plus the error above
Dim xp As SqlDataReader = getStoreProcedu res("StoreProce dure")
End Function
Public Function getStoreProcedu res() As SqlDataReader
Dim sp As SqlDataReader =
CCMSDB.DBDataRe ader("procSelec tBatchReports")
'This sp.Read returns rows displayed in the message box fine.
While sp.Read
MsgBox(sp("Stor eProcedure"))
End While
'This code works fine until here
getStoreProcedu res = sp
'After this, when it returns to Testint, it will blow up
end function
Can anyone help please? I'm new to VB.NET. Thanks in advance,
James
function but got nothing back and a message saying "An unhandled
exception of type 'System.NullRef erenceException ' occurred in
Throw.exe. Object reference not set to an instance of an object."
Here is my code:
Public Function testint() As String
'Nothing returns here, plus the error above
Dim xp As SqlDataReader = getStoreProcedu res("StoreProce dure")
End Function
Public Function getStoreProcedu res() As SqlDataReader
Dim sp As SqlDataReader =
CCMSDB.DBDataRe ader("procSelec tBatchReports")
'This sp.Read returns rows displayed in the message box fine.
While sp.Read
MsgBox(sp("Stor eProcedure"))
End While
'This code works fine until here
getStoreProcedu res = sp
'After this, when it returns to Testint, it will blow up
end function
Can anyone help please? I'm new to VB.NET. Thanks in advance,
James
Comment