Solved

VFP, Append Grid data to a table

Posted on 2010-08-20
3
1,399 Views
Last Modified: 2012-05-10
Working with VFP 9.0 SP2.  

I am working with a web store where I am downloading store orders.  I have a one-to-many relation. One order/customer info. to many items purchased.  I have a filtered the remote view  into a cursor of the items purchased, and have a grid populated from the cursor.   What is the best way to save the grid data, or cursor into a VFP table?   I'm not sure because it is the multiple records.

Thanks
0
Comment
Question by:jws2bay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
jrbbldr earned 500 total points
ID: 33489392
Assuming you have a Grid Cursor (perhaps aliased as GridCursor)
And assuming that you want the data to go into MyTable which has the exact same field structure
And assuming that there is at least one field (DesirdFld) which can be used to differentiate empty records from non-empty records.....
IF !USED('MyTable')   USE MyTable IN 0ENDIFSELECT MyTableAPPEND FROM DBF('GridCursor') FOR !EMPTY(DesirdFld)
NOTE - If the GridCursor and MyTable have different structures and/or need to be handled in some different manner (for example: say you want the Grid data into 2 separate VFP tables), then you will need to use another approach.   But you haven't told us enough to determine if that is necessary.

Good Luck
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33490906
If you'd use the remote instead of copying to a secondary cursor to display the items, then you TABLEUPATE(.T.) to update all rows of the view at once. You need an updatable view of course.

Instead of filtering all items of all orders of all customers perhaps, you parameterise the remote view to only retrieve the items of a single order in the first place.

Bye, Olaf.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33490936
Besides that, if you really want a local copy of order data and not update the web backend, you can use append to a local table, true. You could also COPY TO a new dbf to create a local table with exact same structure in the first place.

Select alias
COPY TO mytable.dbf DATABASE somedbc

You'd only need to do this once, if some.dbf doesn't exist already, and afterwards would use the code of jrbbldr. Both COPY TO and APPEND do respect the filter setting on the grid cursor, you only ned the FOR clause to apply further filtering.

Bye, Olaf.
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
We take a look at some of the most common obstacles that IT teams run into as they work relentlessly to keep all the alarms and sirens from going off at once.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question