Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COM Objects for Fox Pro

Status
Not open for further replies.

moretickets

Technical User
Jul 1, 2000
17
JM
Hi there,

I am programming in VBScript and was wondering if there are COM objects for fox pro that can be used to query a database and retrieve information from a table. If there are COM objects where can I get some documentation on them? Thanks
David
 
Hi David,

The answer to your question is yes, VFP is exposed via COM. You can find documentation in the VFP help file, programmer's guide, or MSDN. The methods you will be most interested in are:

DataToClip-This method allows you to place X number of records to the clipboard.
DoCmd-This method executes a native VFP command.
Eval-This method evaluates a VFP expression and returns the result.
RequestData-This method returns data in an array for the number of records you specify.

Here's an example:

*create the server
oVFP=CreateObject('VisualFoxPro.Application')
*open your table
oVFP.DoCmd('USE MyTable')
*return the first record in an array
MyArray=oVFP.RequestData('MyTable',1)
*place the first record in the clipboard
oVFP.DataToClip('MyTable',1)
*return a specific record
MyVar=oVFP.Eval('MyTable.MyField')

One thing to remember. If you're going to automate VFP, it has to be installed on that machine. So if this is a distributed app, this isn't feasible, AFAIK. That is, unless your clients have VFP, and that's highly unlikely.

You may wanna look into using VFP's ODBC drivers. For an example, check the FAQ area of this forum, FoxDev's FAQ will get you going in the right direction.
 
If you were using DCOM, VFP wouldn't necessarily need to be installed on the machine running the VBScript - but it would certainly have to be installed on the "server" actually running the instance of VFP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top