fwipho
asked on
Update foxpro dbf from c# problem (Syntax Error)
I am having problems updating a foxpro table from c#
The code I am using is : Any ideas on what is happening . Currently I am getting Syntax error as exception.
Do I have to do the update command slightly different when updating a foxpro table!
// Read all required data
damodreg = new OleDbDataAdapter("Select field, mrindex from modreg ", MyConn);
//OleDbCommandBuilder MyCommand = new OleDbCommandBuilder(damodr eg);
damodreg.Fill(dtModreg);
String UpdateCmd = "Update modreg set field= @field where index = @index";
OleDbCommand cmdupdate = new OleDbCommand(UpdateCmd, MyConn);
cmdupdate.Parameters.Add(" @field", OleDbType.VarChar, 20,"field");
OleDbParameter Prm = cmdupdate.Parameters.Add(" @index", OleDbType.Integer,5,"index ");
Prm.SourceVersion = DataRowVersion.Original;
damodreg.UpdateCommand = cmdupdate;
dtModreg.Rows[i_idx +1 ]["field"] = "updated";
damodreg.Update(dtModreg);
The code I am using is : Any ideas on what is happening . Currently I am getting Syntax error as exception.
Do I have to do the update command slightly different when updating a foxpro table!
// Read all required data
damodreg = new OleDbDataAdapter("Select field, mrindex from modreg ", MyConn);
//OleDbCommandBuilder MyCommand = new OleDbCommandBuilder(damodr
damodreg.Fill(dtModreg);
String UpdateCmd = "Update modreg set field= @field where index = @index";
OleDbCommand cmdupdate = new OleDbCommand(UpdateCmd, MyConn);
cmdupdate.Parameters.Add("
OleDbParameter Prm = cmdupdate.Parameters.Add("
Prm.SourceVersion = DataRowVersion.Original;
damodreg.UpdateCommand = cmdupdate;
dtModreg.Rows[i_idx +1 ]["field"] = "updated";
damodreg.Update(dtModreg);
>OleDbParameter Prm = cmdupdate.Parameters.Add(" @index", OleDbType.Integer,5,"index ");
for integer data types, you don't need to specify the size, and the value of "index" if wrong for sure:
OleDbParameter Prm = cmdupdate.Parameters.Add(" @index", OleDbType.Integer);
for integer data types, you don't need to specify the size, and the value of "index" if wrong for sure:
OleDbParameter Prm = cmdupdate.Parameters.Add("
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
String UpdateCmd = "Update modreg set field= @field where mrindex = @index";