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.DBFTableNa me = tableName;
OleDbConnection oConn = new OleDbConnection (@"Provider=VFP OLEDB.1;Data
Source=c:\\" + tableName +";Mode=ReadWri te;");
oConn.Open();
//OleDbCommand oCom = new OleDbCommand("I nsert into
Progress(nProgr ess) values(990)");
OleDbCommand oCom = new OleDbCommand("D elete From Progress");
oCom.Connection = oConn;
oCom.ExecuteNon Query();
oCom = new OleDbCommand("P ACK");
oCom.Connection = oConn;
oCom.ExecuteNon Query();
}
Unhandled Exception: System.Data.Ole Db.OleDbExcepti on: File must be
opened exclusively.
**Removed Several Lines**
at OrderHeader.For m1.Main() in c:\documents and settings\scottm \my
documents\visua l studio projects\orderh eader\form1.cs: line 126 3 24302
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.co m
<aaa> wrote in message news:ej******** *****@TK2MSFTNG P10.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.DBFTableNa me = tableName; OleDbConnection oConn = new OleDbConnection (@"Provider=VFP OLEDB.1;Data Source=c:\\" + tableName +";Mode=ReadWri te;"); oConn.Open(); //OleDbCommand oCom = new OleDbCommand("I nsert into Progress(nProgr ess) values(990)"); OleDbCommand oCom = new OleDbCommand("D elete From Progress"); oCom.Connection = oConn; oCom.ExecuteNon Query(); oCom = new OleDbCommand("P ACK"); oCom.Connection = oConn; oCom.ExecuteNon Query(); }
Unhandled Exception: System.Data.Ole Db.OleDbExcepti on: File must be opened exclusively. **Removed Several Lines** at OrderHeader.For m1.Main() in c:\documents and settings\scottm \my documents\visua l studio projects\orderh eader\form1.cs: line 126
In news:%2******** **********@TK2M SFTNGP10.phx.gb l,
Nicholas Paldino [.NET/C# MVP] <mv*@spam.guard .caspershouse.c om> posted: 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".
Hi Nicholas,
The FoxPro command SET DELETED ON hides deleted records. It corresponds to
the Deleted checkbox in the ODBC driver setup - in other words, when the box
is checked, DELETED is ON and deleted records are hidden. A little
counterintuitiv e.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP ci************* *@mvps.org, www.cindywinegarden.com
In news:ej******** *****@TK2MSFTNG P10.phx.gbl,
aaa <aaa> posted: 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.
When a FoxPro record is marked for deletion you can consider it to be
deleted, as long as you're running with Deleted set ON. The reasons to
permanently remove records are few - if your tables are becoming impossibly
large, or if you need to re-use a primary key. IMHO a key value that's
reused isn't really a PK. Is there some specific reason you need to PACK the
table? Be aware that having exclusive use of the table can only be done when
the users are out of the system.
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.
Um - which error - do you get an error from the Delete command, an error
when you try to PACK, or an error when you try some operation that requires
the records to be permanently removed?
.... oCom = new OleDbCommand("P ACK");
Unhandled Exception: System.Data.Ole Db.OleDbExcepti on: File must be opened exclusively.
The following article describes how to PACK a table via ODBC. It should help
you get started doing it through OLE DB:
HOWTO: Pack a Table Through the Visual FoxPro ODBC Driver (VFPODBC.dll) http://support.microsoft.com/default...b;en-us;234756
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP ci************* *@mvps.org, www.cindywinegarden.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gene Vital |
last post by:
Hi all.
I am using Visual FoxPro via ODBC to update records on a 7.3.4
PostgreSql server and it appears that it always uses delete/insert
instead of updating the current record. Can this be changed to update
the existing record instead?
--
Eugene Vital
Any technology indistinguishable from magic is insufficiently advanced.
|
by: Simon Bailey |
last post by:
I am a newcomer to databases and am not sure which DBMS to use. I have
a very simplified knowledge of databases overall. I would very much
appreciate a (simplifed) message explaining the advantages and
disadvantages of both programs.
Many Thanks
Simon
|
by: Salad |
last post by:
OS = WinXP & Win98. Access = A97 & AXP
Q1) Where can I find the VFP ODBC driver at Microsoft.
I have been working developing an app in Access that will link to some
DOS FoxPro tables.
I have been doing my development work in A97 but the folks have AXP at
their site. As near as I can tell, the FoxPro driver has been discarded
from A97 and replaced with ODBC in A2K onward
|
by: RL Stevenson |
last post by:
Often I want to change the Enable or Visibility on a control when some other
control on the form changes. Or maybe I need to make a change to the
DataSource on a combo box when the user makes a selection elsewhere on the
form.
In Visual FoxPro, you would call Refresh on the form causing Refresh to be
called on all the controls on the form, causing the Refresh event code to be
called and allowing the controls to update themselves to the...
|
by: GPBSOFT |
last post by:
I am Italian developer, escuse me for my bad English
I have a problem with ODBC.
I must link to a database from Visual FoxPro, I have installed Windows XP
Professional with service pack 2. When I try to install driver for Visual
FoxPro i see the message:
“Error 1918. Error installing ODBC driver: Microsoft Visual FoxPro Driver,
ODBC error 13: : Impossibile caricare la libreria di impostazione o del
convertitore. Verify that the file...
| |
by: Sarah |
last post by:
Hi
I am using vb.net
Is it possible to fetch data from foxpro tables (vfp8) and update tables in sql server 2000? The table structures of the foxpro tables are different from those in sql server. Depending on the data fetched, I would like to update relavent table columns in sql server. How can this be done
Regards
Sarah
|
by: Amar |
last post by:
I have a abc.PRG file in visual foxpro 8.0. I can run this file using visual
foxpro environment and it creates a table X.dbf in the same folder where
this program file is and populates some data in the table. I am now using
VB.NET to run this abc.PRG file through VB.net environment. (Equivalent
method to perform same as "DO abc.prg" command in foxpro).
My code for this is as below. This code runs on click of a button in Vb.net.:
Dim Fox...
|
by: Toco |
last post by:
Hello. I have app written in C# that we are testing. The executable is
shared on our network. The method we are testing is a call to a foxpro
table. The call is made to query the table, then fill a datable with the
resultset. All is fine when I run the executable from my machine. However,
when our test user runsthe same executable, the app errors out when
attempting to read from the foxpro table. I have logged where the user...
|
by: z71mdridin |
last post by:
I have an asp.net website that uses Form authentication to
authenticate users. I need to provide users with a report based on
FoxPro data that resides on a remote server. When I attempt to
connect to the Foxpro directory by using the ODBC DSN that we
currently use in ColdFusion, I get the following message:
ERROR File 'table.dbf'
does not exist.
I know this is probably a permissions issue because asp.net is being
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |