DBLib differences with ADO.Net

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

BuddyWork

Hello,

When using multiple queries in DBLib, DBLib would carry on
if the queries failed where ADO.Net stop all the queries.

For example

declare @THStatus char(1)
select @THStatus = '0'
exec Deal_Insert 'ZD4222', 0, @THStatus OUTPUT, 0
select Status = @THStatus

The above query throws a SQL Error in Deal_Insert Stored
procedure and when using DBLib you get the result of the
last query 'select Status = @THStatus' but in C# you don't

The following line of code throws an SQL exception.
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

How can I archive the same as DBLib?

Thanks
 
What's the severity of the error?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Hello Bill,

The error details are as follows.

Class 16
Linenumber 94
Message 'Could not fetch box record -1'
Number 99999
Procedure: Deal_Part_Insert
Source .Net SqlClient Data Provider
Server: ""
State 1

Thanks
 
The "class" is the severity. This means it's a severity 16 exception.
Severities 11-16 are "correctable by the user" but any sev 11 or over throws
an exception (by design). Once an exception of this magnitude is thrown, all
of the data access interfaces (except DBLIB) discard the remaining
resultsets. I discuss conversion from DBLIB in my book "Hitchhiker's Guide
to VBSQL" (1st-3rd Editions) but it won't help as you're using ADO.NET and
those books talk about DAO. My most recent book discusses exception handling
for ADO.NET--it might help.


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top