Update Exception

bwgc

Member
Joined
May 20, 2003
Messages
15
Im trying to code a custom oledbDataAdapter to update a foxpro table. (The commandbuilder wont 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 dont get the error. Ive tried changing the OleDbType.Numeric length to -0- (I read somewhere), but still the same thing.

Anybody?
 
Perhaps one of the rows being updated has a null emp_cost field? Thats what I would assume from the error message being provided.
 
Thats not the case. Its a very small dbf. No null values either in the source or destination.
 
Back
Top