delete records from a DBF table.

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
nyee84Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hiteshgupta1Commented:
USE tablename
DELETE ALL
PACK
DeepDanCommented:
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
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

DeepDanCommented:
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)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fcarandangjrCommented:
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

nyee84Author Commented:
Experts,

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

Best,
Niger
nyee84Author 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
DeepDanCommented:
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
karunamoorthyCommented:
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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FoxPro

From novice to tech pro — start learning today.