Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Update foxpro dbf from c# problem  (Syntax Error)

Posted on 2006-05-31
Medium Priority
Last Modified: 2012-06-27
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);

                    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";
Question by:fwipho
  • 2
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16804834
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";
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16804835
>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);
LVL 96

Accepted Solution

Bob Learned earned 500 total points
ID: 16805457
I don't believe that FoxPro supports named parameters, like @field, @index.


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question