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.SelectComman d = tempSyncSltCmd;
tempCB = new System.Data.OleDb.OleDbCom mandBuilde r(tempSync Adapt);
DataSet dsDBF = new DataSet();
tempSyncAdapt.TableMapping s.Add("Tab le", dbfName);
tempSyncAdapt.Fill(dsDBF, dbfName);
dsDBF.Tables[0].Rows[2].De lete();
tempSyncAdapt.Update(dsDBF , dbfName);
} //End of DBFtoMDB
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
tempSyncSltCmd.Connection = tempSyncConn;
tempSyncAdapt.SelectComman
tempCB = new System.Data.OleDb.OleDbCom
DataSet dsDBF = new DataSet();
tempSyncAdapt.TableMapping
tempSyncAdapt.Fill(dsDBF, dbfName);
dsDBF.Tables[0].Rows[2].De
tempSyncAdapt.Update(dsDBF
} //End of DBFtoMDB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ALTER TABLE - SQL Command
http://msdn.microsoft.com/library/en-us/dv_foxhelp9/html/3c5a454a-67ec-48a8-8290-18dd0e8a97ea.asp?frame=true