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 / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

DataRow throwing exceptions.... but not setting HasErrors?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Z - 09 Nov 2006 23:32 GMT
I'm just learning ADO.NET 1.1 and I'm getting some real stinkers.

I've got a wonderful screwup going on - I'm loading my datatable with a
new datarow.  I used BeginLoadData before I added the row because I
need to bind to that row in the datatable.  I the use "BeginEdit" on
the row so that I can leave a mark to cancel back to later if
necessary, and make the changes to the row, and then I call "EndEdit"
on the datarow to validate the changes.

As expected for the garbage data I entered in, it throws a
DataException.  What blows my mind is that it DOESN'T set the HasErrors
information, or any other error info.  So I have nothing but the
friggin' exception to show the user.  What do I do?  How do I work with
a databound datarow in such a way that I can get useful error info?
Cor Ligthert [MVP] - 10 Nov 2006 04:59 GMT
Martin,

The least thing is to set it inside a try catch block.
Be aware that binding keeps its rules. Even more if you use a strongly typed
dataset.
By instance relations and all other constrains have to be save inside what
you add.

The "if" is the most excelent instruction to test that.

The haserrors is set as you have by instance given the instruction to the
dataadapter to ignore errors. Than the errors are set at update time in the
rows but there is not any error thrown, the complete table is processed,
except the rows which have errors..

I hope this helps,

Cor

> I'm just learning ADO.NET 1.1 and I'm getting some real stinkers.
>
[quoted text clipped - 10 lines]
> friggin' exception to show the user.  What do I do?  How do I work with
> a databound datarow in such a way that I can get useful error info?
Martin Z - 10 Nov 2006 15:25 GMT
Of course I have it in a try-catch-block.  Of course I use "If".  I'm
not talking about basic programming here - I'm asking about the
minimally-documented behaviour of the ADO.Net modules.  The problem is
that there is completely inconsistent behaviour all across ADO.NET -
depending on the order I do things in, the datatable will throw an
exception

a) when I attempt to set the data within the row.
b) when I attempt to call EndEdit().
c) when I attempt to call EndLoadData().

But there is no sensible rhyme or reason to it - and EndEdit does not
set the HasErrors flag, so when EndEdit fails, I can't find the
problem.  Since BeginEdit is called implicitly on any change, there is
no reason that sometimes it will fail on EndEdit and sometimes on
setting the invalid data... and other times it will accept it on
EndData and fail on EndLoadData.

Does anybody know how this mess of Begin and Ends works?  I just want
to add a blank row to the table so I can bind to it, edit the bound
row, and then check for errors if the user clicks "accept" or revert
them if he clicks "cancel" - why is such a simple concept so
horrifically complicated?

> Martin,
>
[quoted text clipped - 29 lines]
> > friggin' exception to show the user.  What do I do?  How do I work with
> > a databound datarow in such a way that I can get useful error info?

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.