Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to code a custom oledbDataAdapter to update a foxpro table. (The commandbuilder won't work in this instance.) My update code follows:

 

string lcSQL = "UPDATE emp SET emp_name=?, emp_cost=? where emp_id=?";

OleDbDataAdapter1.UpdateCommand = new OleDbCommand(lcSQL,this.oleDbConnection1);

oleDbDataAdapter1.UpdateCommand.Parameters.Add("@emp_name", OleDbType.Char, 35,"emp_name");

oleDbDataAdapter1.UpdateCommand.Parameters.Add("@emp_cost", OleDbType.Numeric, 10,"emp_cost");

oleDbDataAdapter1.UpdateCommand.Parameters.Add("@emp_id", OleDbType.Char, 4,"emp_id");

 

When I "oleDbDataAdapter1.Update" with the dataset, I get a "Object Reference Not Set to an instance of an object".

 

If I omit the "emp_cost" field, I don't get the error. I've tried changing the OleDbType.Numeric length to -0- (I read somewhere), but still the same thing.

 

Anybody?

Posted
Perhaps one of the rows being updated has a null emp_cost field? That's what I would assume from the error message being provided.
Gamer extraordinaire. Programmer wannabe.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...