B
Benton
Hi there,
I am getting a null exception when updating a dataset with my own update
command. In the table, the "ID" field is the Primary Key.
Here's the code:
// Select Command preparation
FbCommand selCmd = new FbCommand("SELECT * FROM SAADUANA", conn);
DataSet ds = new DataSet();
FbDataAdapter da = new FbDataAdapter(selCmd);
da.Fill(ds);
// Update Command preparation
string text = "UPDATE SAADUANA SET DESCRIPTION=@DESCRIPTION WHERE ID=@ID";
FbCommand updCmd = new FbCommand(text, conn);
updCmd.Parameters.Add("@ID", FbDbType.SmallInt, 0);
updCmd.Parameters.Add("@DESCRIPTION", FbDbType.VarChar, 150);
da.UpdateCommand = updCmd;
// Data is changed
DataRow firstRow = ds.Tables[0].Rows[0];
firstRow["DESCRIPTION"] = "ANYTHING";
da.Update(ds); <-- Exception here
System.NullReferenceException was unhandled
"Object reference not set to an instance of an object."
Am I missing something? I appreciate any help or comments.
Best Regards,
-Benton
I am getting a null exception when updating a dataset with my own update
command. In the table, the "ID" field is the Primary Key.
Here's the code:
// Select Command preparation
FbCommand selCmd = new FbCommand("SELECT * FROM SAADUANA", conn);
DataSet ds = new DataSet();
FbDataAdapter da = new FbDataAdapter(selCmd);
da.Fill(ds);
// Update Command preparation
string text = "UPDATE SAADUANA SET DESCRIPTION=@DESCRIPTION WHERE ID=@ID";
FbCommand updCmd = new FbCommand(text, conn);
updCmd.Parameters.Add("@ID", FbDbType.SmallInt, 0);
updCmd.Parameters.Add("@DESCRIPTION", FbDbType.VarChar, 150);
da.UpdateCommand = updCmd;
// Data is changed
DataRow firstRow = ds.Tables[0].Rows[0];
firstRow["DESCRIPTION"] = "ANYTHING";
da.Update(ds); <-- Exception here
System.NullReferenceException was unhandled
"Object reference not set to an instance of an object."
Am I missing something? I appreciate any help or comments.
Best Regards,
-Benton