473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Trapping data update exceptions

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
Mar 15 '08 #1
3 1180
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

"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:e%****************@TK2MSFTNGP02.phx.gbl...
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
Mar 15 '08 #2
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
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:B9**********************************@microsof t.com...
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

"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:e%****************@TK2MSFTNGP02.phx.gbl...
>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

Mar 15 '08 #3
John,

John,

Have a look at this one, that is the equivalent of the SQLException

http://msdn2.microsoft.com/en-us/lib...on(vs.71).aspx

Cor


The concurrency vialotions come in your ex because there is nothing wrong
with
"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
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
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:B9**********************************@microsof t.com...
>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

"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:e%****************@TK2MSFTNGP02.phx.gbl...
>>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

Mar 16 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JWA | last post by:
Hi All, How can you capture unhandled exceptions thrown by an MDI child form separate from the entire app? I have an application-wide exception handler to catch crashes by doing the following...
3
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
3
by: windandwaves | last post by:
Hi Gurus Does anyone know how I set the error trapping to option 2 in visual basic. I know that you can go to tools, options and then choose on unhandled errors only, but is there a VB command...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
19
by: KKramsch | last post by:
One of the features from other languages that I miss most in C is trappable exceptions. More specifically, I think it's great to be able to demarcate a whole block of code where several exceptions...
4
by: Mike | last post by:
I have a C# aspx page that calls a C# class file for db access, data, etc. If one of the "functions" I call in the class has an error how can i pass that error back to the aspx page and then...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
5
by: Yash | last post by:
Hi, I have create a user control which has a dropdown. The user control internaly handles the Selected_Index_Changed event of the dropdown. If there is an error/exception in handling it, I would...
3
by: kalyson | last post by:
Hello, I see that Oracle raises its own exceptions for things like this: EXECUTE IMMEDIATE l_sql_stmt INTO l_temp_string; when there is no data found from the query. I don't want to handle...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.