Trapping data update exceptions

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am updating a datatable in a dataset as below;

daMyAdpater.Update(MyDataSet.MyTable)

How can I trap various different exceptions that may occur during this
update process?

Thanks

Regards
 
Try
daMyAdpater.Update(MyDataSet.MyTable)
catch sqlex as SqlException
messagebox.show(sqlex.ToString)
'fixing any SQLTransact code problem
catch ex as Exception
messagebox.show(ex.ToString0
finally
messagebox.show("This will done always as long as you do not power off")
end Try

There is a thirth one you can use, but I never do that.

Cor
 
Hi Cor

Many thanks.

1. Will sqlex.ToString also show Source, Target Site, DataRow and StackTrace
or do I need to show these individually.

2. Would this also trap concurrency violations or do I also need to trap for
DBConcurrencyException? Very sheepishly I want to add I am using Access
backend instead of SQL Server. I am hoping to upgrade to SQL Server soon in
next phase.

Thanks again.

Regards
 
Back
Top