Update foxpro dbf from c# problem  (Syntax Error)

Posted on 2006-05-31
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
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    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 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    >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

    I don't believe that FoxPro supports named parameters, like @field, @index.


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    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…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now