473,387 Members | 1,476 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,387 software developers and data experts.

Error message with AutoNumber column issue- update DB

I implemented article "Inserting relational data using DataSet and
DataAdapter" from this link:
http://www.codeproject.com/cs/databa...onaladonet.asp In my code.

It has a perfect explanation; still I got stuck at one point.
Debugger shows, that it happens when I'm at this stage:

static void CustDataAdapter_OnRowUpdate(object sender,
OleDbRowUpdatedEventArgs e) { OleDbCommand custCmd = new
OleDbCommand("SELECT @@IDENTITY", e.Command.Connection); //right
after this line e.Row["CustID"] =
custCmd.ExecuteScalar(); e.Row.AcceptChanges(); }

This method defines the OleDbRowUpdatedEventHandler event, which comes
to solve the AutoNumber column issue.

I got a message box error:

Problem populating dataset Box: [System.NullReferenceException: Object
reference not set to an instance of an object at (object sender,
OleDbRowUpdatedEventArgs e) in [path to file name]
There is some more text below it, but this seems to be the main thing.
Why do I get NullReferenceException? What did I missed?
sea#

Nov 17 '05 #1
2 1665
sea#

Can you compile this assembly in debug mode and find the line where it
occurs? Or does it occur outside your code? If you get this in debug mode,
it should tell you the line where it occurs, which will help to narrow it
down.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sea#" <ro*****@zahav.net.il> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I implemented article "Inserting relational data using DataSet and
DataAdapter" from this link:
http://www.codeproject.com/cs/databa...onaladonet.asp In my code.

It has a perfect explanation; still I got stuck at one point.
Debugger shows, that it happens when I'm at this stage:

static void CustDataAdapter_OnRowUpdate(object sender,
OleDbRowUpdatedEventArgs e) { OleDbCommand custCmd = new
OleDbCommand("SELECT @@IDENTITY", e.Command.Connection); //right
after this line e.Row["CustID"] =
custCmd.ExecuteScalar(); e.Row.AcceptChanges(); }

This method defines the OleDbRowUpdatedEventHandler event, which comes
to solve the AutoNumber column issue.

I got a message box error:

Problem populating dataset Box: [System.NullReferenceException: Object
reference not set to an instance of an object at (object sender,
OleDbRowUpdatedEventArgs e) in [path to file name]
There is some more text below it, but this seems to be the main thing.
Why do I get NullReferenceException? What did I missed?
sea#

Nov 17 '05 #2
Sorry for missing where you marked the line. It's hard to tell when
it's wrapped around in the reader.

If it happens on this line:

OleDbCommand custCmd = new OleDbCommand("SELECT @@IDENTITY",
e.Command.Connection);

Then it would indicate to me that either e is null (unlikely), or
Command is null, or Connection is null. What are these values when you
check them in the debugger (before this line is executed)?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sea#" <ro*****@zahav.net.il> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I implemented article "Inserting relational data using DataSet and
DataAdapter" from this link:
http://www.codeproject.com/cs/databa...onaladonet.asp In my code.

It has a perfect explanation; still I got stuck at one point.
Debugger shows, that it happens when I'm at this stage:

static void CustDataAdapter_OnRowUpdate(object sender,
OleDbRowUpdatedEventArgs e) { OleDbCommand custCmd = new
OleDbCommand("SELECT @@IDENTITY", e.Command.Connection); //right
after this line e.Row["CustID"] =
custCmd.ExecuteScalar(); e.Row.AcceptChanges(); }

This method defines the OleDbRowUpdatedEventHandler event, which comes
to solve the AutoNumber column issue.

I got a message box error:

Problem populating dataset Box: [System.NullReferenceException: Object
reference not set to an instance of an object at (object sender,
OleDbRowUpdatedEventArgs e) in [path to file name]
There is some more text below it, but this seems to be the main thing.
Why do I get NullReferenceException? What did I missed?
sea#

Nov 17 '05 #3

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

Similar topics

9
by: Roger Withnell | last post by:
I'm inserting a new record into an MS SQL database table and I want to obtain the new records autonumber immediately afterwards, as follows: MadminRS.CursorLocation = adUseServer...
22
by: Tom | last post by:
Hi, I am always confused about what to use as the key for a table. Let's say I have a company-employee table. ---* My co-worker likes to use an AutoNumber or Counter as the key for the ...
5
by: Ed Havelaar | last post by:
I have a cool function that I want to use as a default value for a column in my table. But I can't because apparently Access doesn't allow user defined functions in expressions for default values....
1
by: Mike Wiseley | last post by:
You can create a query in the SQL view that adds a new column to a table. For example, to add a new text field named X10, you use the following language: Alter Table MyTargetTable1 Add Column...
0
by: Megan | last post by:
Hi Everybody- I know that this is a really, really long post, but I wanted to try to give you as much background as possible. So here's a quick overview of the issues I'm asking for help with:...
2
by: Ed Havelaar | last post by:
Hi, Hope someone can help. Here's the scenario: I have two MSAccess tables MainTab and SubTab. MainTab has an autonumber 'id' column as primary key. Subtab has this id column as a foreign...
2
by: Materialised | last post by:
Hi All, I am writing a program in C, which will be driving via a MS Access database. I am relitivly new to database design, so if anyone could help me with my issue I would be greatful. I have...
3
by: Richard Finnigan | last post by:
Hi I was wondering if anyone could help me with this problem. I've been using VWD and my webhost ( a shared hosting package) have told me that the MSQL express files wont work on thier server so...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
4
by: lamkelf | last post by:
Hi all, I have found solution for previous Access versions (i.e. compacting database) but it doesn't work with the 2003 version. Can someone point me to a website or give me some hints. ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.