delete records from a DBF table.

nyee84
nyee84 used Ask the Experts™
on
I have one DBF table names Sales and got one field called Serialno .

I need to delete away all the records from the above mentioned table & manged open the table using visual foxpro but do how can i exceute the commands.

Since i am very new to foxpro IDE, please explain the steps in detail..

Regards,
Niger
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006
Commented:
USE tablename
DELETE ALL
PACK
Top Expert 2006

Commented:
Commented:
actually in case of deleteing all the records in the table its better to use the ZAP command cause it automatically deletes all + packs in 1 command

in your case:

USE Sales EXCLUSIVE
ZAP

if you need further assistance let me know
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Commented:
since you're very new let me give you more steps:

you can not just say USE table if FoxPro is not initilized in the same folder of the table

so put in the comand wondow SET DEFAULT TO GETDIR() and choose the folder where your table is found
then
USE Sales EXCLUSIVE
ZAP

if you want to add new record
APPEND BLANK gives you a blank record to fill after that you can use REPLACE Serialno WITH 001111990 && since this is a serial number i assume your filed is numeric

or you can directly use the insert command to inser values without appending blank
ie INSERT INTO Sales (Serialno)       VALUES (001111990)
if you are not sure where SALES.DBF is, at the command window type

USE ? EXCLUSIVE

it will open up a dialog box and you can look for SALES.DBF, double click on it or click Open.

then theres two way to delete all the records. either:

ZAP

or

DELETE ALL
PACK

Author

Commented:
Experts,

Let me try ur code, will revert to you soon..

Best,
Niger

Author

Commented:
Hi Experts,

I have opened the dbf table and typed the below code in command prompt

USE ? EXCLUSIVE

Selected the table and when i hv used ZAP comand , I encountered an error message "Cannot update the cursor"

How do i resolve the above issue??

Best,
Niger

Commented:
if you have included tha table that you want to ZAP in the project of the your exe, you can not ZAP it
-you include a dbf in the project, cause you dont want anything to change it... eventually you can not ZAP it, DELETE or UPDATE programmatically...

OR maybe you have SET SAFETY ON

please check this 2 and get back
My Dear nyee84,

>> I encountered an error message "Cannot update the cursor"

The possible cause may be due to read only file attribute of your foxpro dbf file.
To chack for that, simply right click the dbf file icon in explorer and click properties and then click the general tab and see whether read only attribute in checked.

Now to sresolve this issue, simply uncheck the read-only attribute(i.e. remove tick mark of ready-only) and then click ok.

Now you try the
USE
ZAP
commands.

hope it solves your problem.

For more information, check out the URL:
http://support.microsoft.com/kb/q294469/


From
Karunamoorthy.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial