aaa,
Technically, when you issue a delete, the rows are flagged with a delete
flag. You aren't going to see those rows on subsequent selects unless the
runtime for foxpro has "SET DELETE ON". If you want to pack the tables, you
shouldn't do this after every database operation, as it can be costly. I
would recommend issuing a pack as part of a regular maintinence and not on
every database operation.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
<aaa> wrote in message news:ej*************@TK2MSFTNGP10.phx.gbl...
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