Solved

VFP, Append Grid data to a table

Posted on 2010-08-20
3
1,341 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now