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(damodreg);
                    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);
fwiphoAsked:
Who is Participating?
 
Bob LearnedCommented:
I don't believe that FoxPro supports named parameters, like @field, @index.

Bob
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if the field is called mrindex (as in the query), should the update not use that name? (just a guess)

                    String UpdateCmd = "Update modreg set field= @field where mrindex = @index";
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.