Debugging into SqlCommand.ExecuteReader

  • Thread starter Thread starter BuddyWork
  • Start date Start date
B

BuddyWork

Does anyone know if there are any articles explaining how
I could debug into SqlCommand.ExecuteReader so I can see
why I am getting a particular error.

thanks
 
There are many possible ways... what is the specific error you are getting.
The approach you take to figure it out is heavily dependent on this.
However, I'd wrap it all in a try catch block trapping SqlException and
ex.ToString ..that will probably tell you most of what you'll need.
 
Hello,

The problem is that when using SqlCommand.ExecuteReader
and the SQL statement raises an error of severity of 16
then ExecuteReader throws an exception, when you use
OdbcCommand.ExecuteReader the exception is not raised but
when you call Read() method of the OdbcDataReader you then
get the exception which is correct, basically SqlClient
does not let you call the Read method, the main problem is
that if run a Sql statement of say
'Need to create the following SP first.
create proc test
as
rollback tran
go

now run the following SQL through SqlCommand and then
OdbcCommand
begin tran
execute test
select hello="World"

you will notice that SqlCommand throws an exception on
ExecuteReader function where OdbcCommand does not, so Odbc
allows you to call Read and NextResult to go through the
recordset and retrieve your data, wher SqlClient does not
because you don't get the SqlDataReader object back.

Thanks,
 
Buddy:

It's the proc you are using. It throws an exception because of the snytax.
As far as why ODBC behaves differently, it's because you aren't calling the
same thing in both instances. If you run your proc in QA, it blows up with
a severity level of 16. That's all the SqlException is telling you.
 
I've had a Microsoft Engineer to have a look and he
agrees that Odbc.ExecuteReader does NOT throw an
exception where SqlClient.ExecuteReader does, he has now
escalated it to the states.
 
Back
Top