I'm having a little problem with my code. Im trying to update a record using OleDbCommand.
This is the initializer code:
And here's how it's used:
The system raises the error:
And breaks to
part.
How do I get additional information on the exception? This is the same message when a constraint violation occurs.
I just found out so while doing trial and error on code segments, and not much of a help.
Funny, I was able to make Insert statement work, but not Update. It's very obvious I'm missing something
out here, but, pity me...
TIA
This is the initializer code:
Code:
strSQL = "UPDATE CUSTOMER SET " +
"NAME=?, CTCPERSION=?, ISVAT=?, ISACTIVE=?, NATURE=?, COUNTRY=?, REMARKS=? " +
"WHERE ID=?;";
cmdUpdate = new OleDbCommand(strSQL, CGateKeeper.conSales);
cmdUpdate.CommandType = CommandType.Text;
cmdUpdate.Parameters.Add("name" , OleDbType.VarChar, 150);
cmdUpdate.Parameters.Add("ctcperson", OleDbType.VarChar, 50);
cmdUpdate.Parameters.Add("isvat" , OleDbType.Boolean);
cmdUpdate.Parameters.Add("isactive" , OleDbType.Boolean);
cmdUpdate.Parameters.Add("nature" , OleDbType.Integer);
cmdUpdate.Parameters.Add("country" , OleDbType.VarChar, 20);
cmdUpdate.Parameters.Add("remarks" , OleDbType.VarChar, 200);
cmdUpdate.Parameters.Add("id" , OleDbType.Integer);
And here's how it's used:
Code:
tran = CGateKeeper.conSales.BeginTransaction(IsolationLevel.ReadCommitted);
cmdUpdate.Parameters["id"].Value = file.ID;
cmdUpdate.Parameters["name"].Value = file.Name;
cmdUpdate.Parameters["ctcperson"].Value = file.CtcPerson;
cmdUpdate.Parameters["isvat"].Value = file.IsVat;
cmdUpdate.Parameters["isactive"].Value = file.IsActive;
cmdUpdate.Parameters["nature"].Value = file.Nature;
cmdUpdate.Parameters["country"].Value = file.Country;
cmdUpdate.Parameters["remarks"].Value = file.Remarks;
cmdUpdate.Transaction = tran;
recAffect = cmdUpdate.ExecuteNonQuery();
tran.Commit();
The system raises the error:
Code:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
Code:
recAffect = cmdUpdate.ExecuteNonQuery();
How do I get additional information on the exception? This is the same message when a constraint violation occurs.
I just found out so while doing trial and error on code segments, and not much of a help.
Funny, I was able to make Insert statement work, but not Update. It's very obvious I'm missing something
out here, but, pity me...
TIA