Welcome! Log In Create A New Profile

Advanced

Visual Foxpro data bases (dbc)

Posted by javier garcia.pcs.crosspost 
javier garcia.pcs.crosspost
Visual Foxpro data bases (dbc)
July 28, 2008 09:33AM
Hello everyone, I need to open a database (dbc) of visual foxpro.
If the table attached to the analysis as native access for WD, the file doesn't read well, only read 3 of the nearly 30000 records in the file. And if I do so through ODBC, then I can't use the table to create a query with the wizard.
I want to open the table, read all the records and that could create a query from it.
Someone may help me.
Thanks for your help.
I use WinDev XII with Windows Vista.

Message forwarded from pcsoft.us.windev
David Martin
Re: Visual Foxpro data bases (dbc)
July 28, 2008 02:44PM
To access VFP DBCs use the OLE/DB provider. You can download it here:
<pre>
[www.microsoft.com]
</pre>
Here is a sample of how to access a a VFP DBF via OLE/DB. I am accessing the DBFs directly but the principle is the same for accessing them via DBCs.
<pre>
// Define some variables for access the DBF via OLE/DB
cn_VFPData is Connection
ds_VFPData is Data Source
l_sQueryString is string

// Fill in items in the Connection
cn_VFPData..User = ""
cn_VFPData..Password = ""
cn_VFPData..Server = "localhost"
cn_VFPData..Database = ""
cn_VFPData..Source = "I:\ProgDir\DataDir"
cn_VFPData..Provider = "VFPOLEDB.1"
cn_VFPData..Access = hOReadWrite
cn_VFPData..ExtendedInfo = ""

// Open the Connection
IF NOT HOpenConnection( cn_VFPData ) THEN
Info(HErrorInfo())
END

// Build the query in a String variable
// -----------------
// Note 1: The variable is enclosed in double quotes so we need to use either
// single quotes or [] brackets to enclose text within the query string
// -----------------
// Note 2: This is VFP SQL here, type it as if you were going to execute it from
// the VFP command window
sQueryString = "SELECT field1, field2, filed3, field4 FROM VFP_DBF WHERE TextField='ABCD' AND NumericField=1234 AND DTOS(DateField) = '20080728'"
IF NOT HExecuteSQLQuery(ds_VFPData, cn_VFPData, hQueryWithoutCorrection, sQueryString) THEN
Info(HErrorInfo())
END

// Set to True to view results via the WinDev BuildBrowsingTable function
IF True THEN
BuildBrowsingTable(TABLE_VFPData, ds_VFPData, taFillTable)
{"TABLE_VFPData._COL4"}..InputMask = "MM/DD/YYYY"
END

// Set to True to step through results and add them to a WinDev Table
IF False THEN
HReadFirst(ds_VFPData)
TableDeleteAll(TABLE_VFPData)
WHILE HOut(ds_VFPData) = False
TableAddLine(TABLE_VFPData, ds_VFPData.field1, ds_VFPData.field2, ds_VFPData.field3, ds_VFPData.field4)
HReadNext(ds_VFPData)
END
END

HCancelDeclaration(ds_VFPData)

HCloseConnections(cn_VFPData)
</pre>

For more information see the following topics in the VFP help file:

How to: Access Visual FoxPro Data in Visual Studio

Language Reference for OLE DB Development





Edited 4 time(s). Last edit at 07/28/2008 07:22PM by David Martin.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: