Connect to Foxpro Data (*.DBF) in VB.Net

G

Guest

Dear All

We are currently write a program to "Transfer" Data from old system.

How can i connect to a set of DBF files by
What is the connection string to connect the DBF?
I have try this one but error.
connstr = "Provider = VFPOLEDB;Data Source=" & "C:\ESS2001\DATA\"

I have the following question?
1. Does [OleDBConnection] Object support DBF Files? or i should use
[ODBCConnection] ?
2. Should I it a must to have a "*.dbc" file ?
3. I need to use ADO instead of ADO.Net in VB.Net ?

Thank you for your help in advance!
 
C

Cindy Winegarden

Hi Eric,

First of all, be sure you have the latest FoxPro and Visual FoxPro OLE DB
data provider, available from msdn.microsoft.com/vfoxpro/downloads/updates.
ODBC is an older technology and does not support all versions of FoxPro
tables.

FoxPro tables come in 3 parts: the DBF is the main table, the FPT (optional)
is the contents of Memo fields, and the CDX (also optional) is the
associated index file. All three of these generally named the same excepting
the extension and if your table has Memo fields and indexes then the FPT and
CDX must be present.

There are two ways Fox tables are organized. First, there are "free" tables.
With free tables a DBC file is not present and the connection string should
reference only the directory where the files are found, as you have done
below.

Second, Fox tables can be associated with a "Database Container" (DBC, DCT
memo, and DCX index files) which contains metadata about the tables and
other features such as stored procedures and triggers. If a DBC is present
the path in your connection string should be something like
"C:\ESS2001\DATA\Whatever.dbc" .

You can use the same types of ADO.NET code for Fox tables as you would for
any other OLE DB-compliant data source.
 
P

Paul Clement

¤ Dear All
¤
¤ We are currently write a program to "Transfer" Data from old system.
¤
¤ How can i connect to a set of DBF files by
¤ What is the connection string to connect the DBF?
¤ I have try this one but error.
¤ connstr = "Provider = VFPOLEDB;Data Source=" & "C:\ESS2001\DATA\"
¤

What is the name of your database? I don't see it in the connection string.

¤ I have the following question?
¤ 1. Does [OleDBConnection] Object support DBF Files? or i should use
¤ [ODBCConnection] ?

Yes. No don't use ODBC. Those drivers are outdated.

¤ 2. Should I it a must to have a "*.dbc" file ?

I believe that would be required by the OLEDB provider, yes.

¤ 3. I need to use ADO instead of ADO.Net in VB.Net ?

No, you can use ADO.NET.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
C

Cindy Winegarden

Hi Paul,

See my post in this thread for a little discussion of working with Fox data
in .NET. :)
 
G

Guest

Hi Cindy,

I have fixed my problem after i download the
OleDB Provider for VFP 9.0 in Microsoft Site

http://www.microsoft.com/downloads/...8f-2d58-491f-a0fa-95a3289c5fd4&DisplayLang=en

My Connection String as follow is workable
"Provider = VFPOLEDB;Data Source=C:\DBFPath\To_eric;Mode=Read;Collating
Sequence=MACHINE;"

I am using "Free Table" method as my user would like to choose where even
"DBF" file they need.

Thank you for you and other help.

--
EricLun


Cindy Winegarden said:
Hi Eric,

First of all, be sure you have the latest FoxPro and Visual FoxPro OLE DB
data provider, available from msdn.microsoft.com/vfoxpro/downloads/updates.
ODBC is an older technology and does not support all versions of FoxPro
tables.

FoxPro tables come in 3 parts: the DBF is the main table, the FPT (optional)
is the contents of Memo fields, and the CDX (also optional) is the
associated index file. All three of these generally named the same excepting
the extension and if your table has Memo fields and indexes then the FPT and
CDX must be present.

There are two ways Fox tables are organized. First, there are "free" tables.
With free tables a DBC file is not present and the connection string should
reference only the directory where the files are found, as you have done
below.

Second, Fox tables can be associated with a "Database Container" (DBC, DCT
memo, and DCX index files) which contains metadata about the tables and
other features such as stored procedures and triggers. If a DBC is present
the path in your connection string should be something like
"C:\ESS2001\DATA\Whatever.dbc" .

You can use the same types of ADO.NET code for Fox tables as you would for
any other OLE DB-compliant data source.


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
(e-mail address removed) www.cindywinegarden.com


How can i connect to a set of DBF files by
What is the connection string to connect the DBF?
I have try this one but error.
connstr = "Provider = VFPOLEDB;Data Source=" & "C:\ESS2001\DATA\"

I have the following question?
1. Does [OleDBConnection] Object support DBF Files? or i should use
[ODBCConnection] ?
2. Should I it a must to have a "*.dbc" file ?
3. I need to use ADO instead of ADO.Net in VB.Net ?
 
C

Cindy Winegarden

Hi Eric,

Just to be clear, if a DBC file is present you should assume all the tables
in that directory belong to it (although they don't have to) and connect to
the DBC. The Fox data engine uses the metadata in the DBC to find the tables
you reference in your app.

If there is no DBC then the tables are most likely free tables. I say "most
likely" because the DBC is not required to be in the same directory as the
DBFs. Also, if the tables have been copied from one directory to another the
DBC may not have been included in the copying. This would, of course, cause
problems.

Free tables and tables belonging to a DBC can be mixed in the same
directory. However, with a free table directory connection the tables
contained by the DBC will not be recognized, and with a connection to the
DBC, any free tables in that directory will not be recognized.

This probably way overcomplicates your situation but I thought I'd discuss
it, since someone searching the archives may need to know these details.
 
G

Guest

I got it! Thank you very much
--
EricLun


Cindy Winegarden said:
Hi Eric,

Just to be clear, if a DBC file is present you should assume all the tables
in that directory belong to it (although they don't have to) and connect to
the DBC. The Fox data engine uses the metadata in the DBC to find the tables
you reference in your app.

If there is no DBC then the tables are most likely free tables. I say "most
likely" because the DBC is not required to be in the same directory as the
DBFs. Also, if the tables have been copied from one directory to another the
DBC may not have been included in the copying. This would, of course, cause
problems.

Free tables and tables belonging to a DBC can be mixed in the same
directory. However, with a free table directory connection the tables
contained by the DBC will not be recognized, and with a connection to the
DBC, any free tables in that directory will not be recognized.

This probably way overcomplicates your situation but I thought I'd discuss
it, since someone searching the archives may need to know these details.
 
P

Paul Clement

¤ Hi Paul,
¤
¤ See my post in this thread for a little discussion of working with Fox data
¤ in .NET. :)

Hi Cindy,

Hey, I didn't do too bad for not being a FoxPro expert. ;-)


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top