G
Guest
Greetings,
I have an issue that I just can seem to get past today. I continually get
the following error:
Invalid attempt to NextResult when reader is closed
This is happening when calling this code, which is our standard block around
a simple fill function:
If cnx.State = ConnectionState.Open Then
cnx.Close()
End If
cnx.Open()
Try
adapterTimeRecords.Fill(DstTimeRecords.app__TimeRecords)
Catch ex As SqlClient.SqlException
MSCError.MSCErrorSQL(ex)
Catch es As SystemException
MSCError.MSCErrorSystem(es)
Catch ea As Exception
MSCError.MSCError(ea)
Finally
If cnx.State = ConnectionState.Open Then
cnx.Close()
End If
End Try
The select command is a simple SQL Statement where the following is the text
of that:
SELECT DISTINCT IDCODE_PERSNNEL, SSN, firstname, lastname, sortpjc FROM
app__TimeRecords where idcode_persnnel in (SELECT idcode_persnnel FROM
app__TimeRecords where idcode_ship = 3 AND PayPeriodID = 1 ) ORDER BY
SortPJC, ssn"
Notes:
- The standard code block ensures that the connection is open prior to the
calling of the fill statement (yes, I know that calling fill also opens the
connection automatically, but why leave anything to chance?)
- If I step through this code, when the adapter is in scope, the debug
window does not throw this error but rather gives me '41' which is correct
and what it should be, having tested this in SQL Profiler.
- when it throws the exception, it does not throw it via the
SQLClient.SQLConnection class, but rather the System.Exception class.
This is really stupid weird, as I have this same fill statement used
elsewhere and it always runs fine.
Michael
I have an issue that I just can seem to get past today. I continually get
the following error:
Invalid attempt to NextResult when reader is closed
This is happening when calling this code, which is our standard block around
a simple fill function:
If cnx.State = ConnectionState.Open Then
cnx.Close()
End If
cnx.Open()
Try
adapterTimeRecords.Fill(DstTimeRecords.app__TimeRecords)
Catch ex As SqlClient.SqlException
MSCError.MSCErrorSQL(ex)
Catch es As SystemException
MSCError.MSCErrorSystem(es)
Catch ea As Exception
MSCError.MSCError(ea)
Finally
If cnx.State = ConnectionState.Open Then
cnx.Close()
End If
End Try
The select command is a simple SQL Statement where the following is the text
of that:
SELECT DISTINCT IDCODE_PERSNNEL, SSN, firstname, lastname, sortpjc FROM
app__TimeRecords where idcode_persnnel in (SELECT idcode_persnnel FROM
app__TimeRecords where idcode_ship = 3 AND PayPeriodID = 1 ) ORDER BY
SortPJC, ssn"
Notes:
- The standard code block ensures that the connection is open prior to the
calling of the fill statement (yes, I know that calling fill also opens the
connection automatically, but why leave anything to chance?)
- If I step through this code, when the adapter is in scope, the debug
window does not throw this error but rather gives me '41' which is correct
and what it should be, having tested this in SQL Profiler.
- when it throws the exception, it does not throw it via the
SQLClient.SQLConnection class, but rather the System.Exception class.
This is really stupid weird, as I have this same fill statement used
elsewhere and it always runs fine.
Michael