Trapping error in DataAdapter.Fill(ds)

R

Rick

I use a DataAdapter (.Net 1.1) to fill a dataset of about 30 tables
using a stored procedure. One of the tables is throwing a constraint
error, and I'd like to figure out which one. Can't debug through the
fill method so any suggestions on how to isolate and identify the
error?

Thanks,
Rick
 
M

Miha Markic [MVP C#]

Hi Rick,

Loop through tables in dataset and check DataTable.HasErrors property.
If you want to pinpoint the row, loop through rows in offending table and
check their HasErrors property.
 
W

William \(Bill\) Vaughn

Sure. Execute the SP via query analyzer.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
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.
__________________________________
 
W

William \(Bill\) Vaughn

Depending on the version of VS you're using, you might also be able to debug
the SP line-by-line.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
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.
__________________________________
 
R

Rick

Thanks - this was the kind of test I was looking for.
The problem is solved and turned out to be two tables in the dataset
being out of order with the select order in the stored procedure.
Interestingly, I re-created the error, looped through the tables and it
did find a table with the haserrors property set, but it was 5 tables
after the mismatch. The intervening tables had no rows selected and
the error property didn't get set until it tried to actually add rows
to a table.
At least it put me in the vicinity of the error.

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top