Link to home
Start Free TrialLog in
Avatar of absolutesolutions
absolutesolutions

asked on

primary key on DBF to get C# app to work

I am tring to update a dbf file with C# in Visual Studio 2003.  I am getting an error on update and delete:
not supported against a SelectCommand that does not return any key column information

In researching this, I have read that it is because my dbf table does not have a primary key.  How do I set up a primary key on a dbf?  I have Visual FoxPro 6.0, but am not fluent in it AT ALL.  I usually work with Access, which is very different than FoxPro.  

I have included code below, just in case it helps:

            private void DBFtoMDB(string mdbName, string dbfName)
            {    
                      tempSyncSltCmd.CommandText = "SELECT * FROM " + dbfName;
                  tempSyncSltCmd.Connection = tempSyncConn;
                  tempSyncAdapt.SelectCommand = tempSyncSltCmd;
                  tempCB = new System.Data.OleDb.OleDbCommandBuilder(tempSyncAdapt);

                  DataSet dsDBF = new DataSet();
                  tempSyncAdapt.TableMappings.Add("Table", dbfName);
                  tempSyncAdapt.Fill(dsDBF, dbfName);

            dsDBF.Tables[0].Rows[2].Delete();


                 tempSyncAdapt.Update(dsDBF, dbfName);
            
            } //End of DBFtoMDB



 
Avatar of CarlWarner
CarlWarner
Flag of United States of America image

You should be somewhat familiar with some SQL stuff and use of the ALTER TABLE command.

ALTER TABLE - SQL Command
http://msdn.microsoft.com/library/en-us/dv_foxhelp9/html/3c5a454a-67ec-48a8-8290-18dd0e8a97ea.asp?frame=true
ASKER CERTIFIED SOLUTION
Avatar of suhashegde
suhashegde

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial