C
Cameron Frasnelly
I emulated the code from the .Net Framework help (Titled "Using Stored
Procedures with a Command") and I still receive and error...
Error Received = "Invalid attempt to read when no data is present."
BUT when I manually run the Stored Procedure and manually type in '3333' it
works just fine by returning the single row for that particular work
order????????
*****More Clues****
- Returning the column name via .GetName works fine
- I am attempting to do this within the class (I don't see why this would be
an issue)
- I have been working on this one single problem for MORE THAN THREE FRI@#%$
HOURS! Just wanted to vent...
*****CODE BELOW*******
'Setup the connection
Dim connObj As New SqlConnection(OpsDB_Module.ConnectionString())
'Setup the command to execute
Dim cmdObj As SqlCommand = New SqlCommand("spWorkOrderFull_byKEY", connObj)
cmdObj.CommandType = CommandType.StoredProcedure
'----add parameter to stored procedure
Dim myParm As SqlParameter = cmdObj.Parameters.Add("@WorkOrderKEY",
SqlDbType.Int)
myParm.Value = 3333
'Open the connection
connObj.Open()
'Grab the data into a reader object
Dim sqlDR As SqlDataReader = cmdObj.ExecuteReader()
'Assign returned values to class properties
Dim tmpString As String = sqlDR.GetName(0) '!!! This Works Just Fine and
returns the column name!!!
Me._WorkOrderKEY = sqlDR.GetInt16(0)
Me._Problem = sqlDR.GetString(sqlDR.GetOrdinal("Problem"))
Me._Priority = sqlDR.GetInt16(sqlDR.GetOrdinal("Priority"))
Procedures with a Command") and I still receive and error...
Error Received = "Invalid attempt to read when no data is present."
BUT when I manually run the Stored Procedure and manually type in '3333' it
works just fine by returning the single row for that particular work
order????????
*****More Clues****
- Returning the column name via .GetName works fine
- I am attempting to do this within the class (I don't see why this would be
an issue)
- I have been working on this one single problem for MORE THAN THREE FRI@#%$
HOURS! Just wanted to vent...
*****CODE BELOW*******
'Setup the connection
Dim connObj As New SqlConnection(OpsDB_Module.ConnectionString())
'Setup the command to execute
Dim cmdObj As SqlCommand = New SqlCommand("spWorkOrderFull_byKEY", connObj)
cmdObj.CommandType = CommandType.StoredProcedure
'----add parameter to stored procedure
Dim myParm As SqlParameter = cmdObj.Parameters.Add("@WorkOrderKEY",
SqlDbType.Int)
myParm.Value = 3333
'Open the connection
connObj.Open()
'Grab the data into a reader object
Dim sqlDR As SqlDataReader = cmdObj.ExecuteReader()
'Assign returned values to class properties
Dim tmpString As String = sqlDR.GetName(0) '!!! This Works Just Fine and
returns the column name!!!
Me._WorkOrderKEY = sqlDR.GetInt16(0)
Me._Problem = sqlDR.GetString(sqlDR.GetOrdinal("Problem"))
Me._Priority = sqlDR.GetInt16(sqlDR.GetOrdinal("Priority"))