G
Guest
I am trying to Delete records from Fox Pro Free Tables (.DBF) using
C#. I am able to insert and view data with no problems but when I try
to delete - no luck. It appears that I need to run a "Pack" command
but I receive the error "File must be opened exclusively." on the Pack
Command. The code is below and the first command "Delete From
Progress" marks all rows for deletion but does not remove them. I've
tried Exclusive=On but still get the same error.
public FoxProConnector(string tableName){
this.DBFTableName = tableName;
OleDbConnection oConn = new OleDbConnection(@"Provider=VFPOLEDB.1;Data
Source=c:\\" + tableName +";Mode=ReadWrite;");
oConn.Open();
//OleDbCommand oCom = new OleDbCommand("Insert into
Progress(nProgress) values(990)");
OleDbCommand oCom = new OleDbCommand("Delete From Progress");
oCom.Connection = oConn;
oCom.ExecuteNonQuery();
oCom = new OleDbCommand("PACK");
oCom.Connection = oConn;
oCom.ExecuteNonQuery();
}
Unhandled Exception: System.Data.OleDb.OleDbException: File must be
opened exclusively.
**Removed Several Lines**
at OrderHeader.Form1.Main() in c:\documents and settings\scottm\my
documents\visual studio projects\orderheader\form1.cs:line 126
C#. I am able to insert and view data with no problems but when I try
to delete - no luck. It appears that I need to run a "Pack" command
but I receive the error "File must be opened exclusively." on the Pack
Command. The code is below and the first command "Delete From
Progress" marks all rows for deletion but does not remove them. I've
tried Exclusive=On but still get the same error.
public FoxProConnector(string tableName){
this.DBFTableName = tableName;
OleDbConnection oConn = new OleDbConnection(@"Provider=VFPOLEDB.1;Data
Source=c:\\" + tableName +";Mode=ReadWrite;");
oConn.Open();
//OleDbCommand oCom = new OleDbCommand("Insert into
Progress(nProgress) values(990)");
OleDbCommand oCom = new OleDbCommand("Delete From Progress");
oCom.Connection = oConn;
oCom.ExecuteNonQuery();
oCom = new OleDbCommand("PACK");
oCom.Connection = oConn;
oCom.ExecuteNonQuery();
}
Unhandled Exception: System.Data.OleDb.OleDbException: File must be
opened exclusively.
**Removed Several Lines**
at OrderHeader.Form1.Main() in c:\documents and settings\scottm\my
documents\visual studio projects\orderheader\form1.cs:line 126