Known Bug - Possible Workaround??
(Tuesday, December 21, 2004)
Found the following interesting discussion in the Newsgroups:
Known Bug - Possible Workaround?? by:CJ Taylor
| Alright, So this morning (as we are a week from launch on our product) I come across an error as I add a simple thing to our system. A display column in our dataset for databinding for display purposes only.
So everything goes smoothly, compile, start running, everything looking good. then I go to update a row.. get a System.Data.Readonly exception.
I investigate further to find this is a known bug in the framework according to many articles. Here is one if you want to read about it some..
http://www.error-bank.com/microsoft.public.dotnet.framework.windowsforms.databinding/_35_hcsyiv0dha.2328@tk2msftngp10.phx.gbl_Thread.aspx
So, I read the "workarounds" which are lame attempts to trick the framework by removing expression columns from the datatable before the update, and then add them back after the update.
Now to me... this sounds really dumb...
So I tried something. I attached to the RowUpdated and RowUpdating events of my DataAdapter. Rowupdating provides nothing useful. However Row Updated comes back with the Sql.Data.ReadonlyException
This sets the Status property of the System.Data.SqlClient.SqlRowUpdatedEventArgs to ErrorsOccured. However, I check the database and my fields were updated as excpected. It's just the fact it can't change the Readonly property on the expression column...
I don't care about that...
So I set the Status to continue if the error is of Data.ReadonlyException
No problems...
I return to the UI Layer... No problems... all changes updated as expceted....
is there anything obvious I'm missing in this? Why this wouldn't work?
Comments appreciated.
Thanks, CJ
| | | Reply: by:OHM
| | | No problems, no problem !
OHM
| | | Reply: by:CJ Taylor
| | | Ha! Like you this is not the answer I wanted.
Ok, then why does about 300 people agree that removing the expression columns is the *best* way. There is no way that I figured out a better way to do it. I'm just not that smart. =)
| | | Reply: by:OHM
| | | I dont really have a good answer, other than if it works consistently, then why worry about it. It's fixed in VS2005 probably anyway.
OHM
| | | Reply: by:scorpion53061
| | | First of all good to hear from you again OHM. havent heard from you in a while.
The challenge of overcoming the issue is the reason I will make myself trying to fix a problem like that which CJ is dealing with.
Something like what happened to me with datatable.compute
Ask Mr.Ryan how crazy I drove him with that one!!
|
|
0 Comments:
Post a Comment