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,