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 / September 2005

Tip: Looking for answers? Try searching our database.

NullReferenceException when you update a column value in OnRowUpdating event handler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jiho Han - 29 Sep 2005 19:47 GMT
I am getting a NullReferenceException deep in the bowels of ADO.NET.

I figured out that it only happens when I change column values within RowUpdating
event handler.

       private void _dataAdapter_RowUpdating(object sender, OleDbRowUpdatingEventArgs
e)
       {
           System.Diagnostics.Debug.WriteLine("QueryTable::OnRowUpdating");
           if (e.Row.Table.Columns.Contains("MODIFYDATE"))
               e.Row["MODIFYDATE"] = DateTime.Now;
           if (e.Row.Table.Columns.Contains("MODIFYUSER"))
               e.Row["MODIFYUSER"] = "ADMIN";
       }

I am simply calling the dataadapter's Update method.  I can only guess that
changing the column value in RowUpdating event is changing the internal state
that makes the whole thing fail.

Two questions:

1. Does anyone know what may be happening?

2. How do I troubleshoot this when an error is happening in the framework
like this?  The disassembly view doesn't really help since I can't read IL.
I tried Reflector add-in which is good but it doesn't take me to the source
line where it's failing.

Thanks and I took out the above code and I am updating those fields before
I call Update method, following the wisdom gained from the following well-known
joke:

"Doctor, it hurts when I do this."
"Then, don't do it."

Jiho
Jiho Han - 29 Sep 2005 22:00 GMT
Ok, scratch that idea.  I am still getting the same error.  But I narrowed
it down to the DateTime field that's causing the problem.

For some reason, my update command will fail whenever I tried to update the
MODIFYDATE field (OleDbType.DBTimeStamp - sql datetime).
I am doing something like:

UPDATE HISTORY SET MODIFYDATE = ?, MODIFYUSER = ?, DESCRIPTION = ? WHERE
MODIFYDATE = ? AND MODIFYUSER = ? AND DESCRIPTION = ? AND HISTORYID = ?

for optimistic concurrency.

> I am getting a NullReferenceException deep in the bowels of ADO.NET.
>
[quoted text clipped - 34 lines]
> "Then, don't do it."
> Jiho

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.