Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

SQLDataAdapter.Update exception reporting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Feng - 09 Jan 2006 21:11 GMT
I am trying to use some code example from MSDN like the following:

Try
SqlDataAdapter1.Update(DataSet1User21, _
 "Shippers")
PopulateGridFromDB()
Catch ex As Exception
...

But for some reason it doesn't work for me this way. Each time an error
occours on the Update, instead of an exception being caught, all I see is
that no exception was thorwn, but the DataRows in the DataSet were populated
with error messages.

Is this configurable? How do I make the system just to throw the exception
so that my code can catch?

Thanks

Feng
Jesús López - 09 Jan 2006 21:21 GMT
The SqlDataAdapter class has the property ContinueUpdateOnError. If this
property is set to true, no exceptions are thrown by the Update method. In
this case you should check DataSet.HasErrors

Regards from Madrid (Spain)
Jesús López
MVP

>I am trying to use some code example from MSDN like the following:
>
[quoted text clipped - 17 lines]
>
> Feng
Andre Botelho - 10 Jan 2006 13:36 GMT
Just to improve your research... you can use the RowUpdated event to
catch the exceptions per datarow during the update process.

I used in a project the code is like this:

private void OnRowUpdated(object sender, SqlRowUpdatedEventArgs e)
{
 if (e.Errors != null)
 {
  string Tablename = e.Row.Table.TableName;
  ErrorList.Append("Error updating table " + Tablename + ": "+
e.Errors.Message + Environment.NewLine);
   for (int Index = 0; Index <= e.Row.Table.Columns.Count + 1; Index++)
   {
    string ColumnName = e.Row.Table.Columns[Index].ColumnName;
    string Value = e.Row[Index].ToString();
       ErrorList.Append(ColumnName + " = " + Value +
Environment.NewLine);
   }
 }
}

ErrorList is a StringBuilder object that I have in the class to log all
exceptions. In the code above the result will be the tablename and all
it's columns and it's values. It helped me a lot in finding some bugs. I
hope it will be useful for you too.

regards from Brazil,

Andre Botelho

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.