Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

161 views
Skip to first unread message

EricLun

unread,
Jan 3, 2006, 3:52:02 AM1/3/06
to
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!

--
EricLun

Cor Ligthert [MVP]

unread,
Jan 3, 2006, 4:16:49 AM1/3/06
to
Eric,

She will answer you probably as well. It seems she is busy again in this
newsgroups.

However if not, have a look at these ansered messages.

http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/search?group=microsoft.public.dotnet.framework.adonet&q=winegarden&qt_g=1&searchnow=Search+this+group

I hope this helps,

Cor


Paul Clement

unread,
Jan 3, 2006, 1:26:31 PM1/3/06
to
On Tue, 3 Jan 2006 00:52:02 -0800, "EricLun" <eric_...@hotmail.com> wrote:

¤ 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)

Cindy Winegarden

unread,
Jan 3, 2006, 12:56:36 PM1/3/06
to
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
cindy_wi...@msn.com www.cindywinegarden.com


"EricLun" <eric_...@hotmail.com> wrote in message
news:127B59E8-4035-47DD...@microsoft.com...

Cindy Winegarden

unread,
Jan 3, 2006, 12:56:47 PM1/3/06
to
Hi Cor,

Thanks! :-)

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_wi...@msn.com www.cindywinegarden.com


"Cor Ligthert [MVP]" <notmyfi...@planet.nl> wrote in message
news:%23MnYZZE...@TK2MSFTNGP11.phx.gbl...

Cindy Winegarden

unread,
Jan 3, 2006, 2:17:18 PM1/3/06
to
Hi Paul,

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

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_wi...@msn.com www.cindywinegarden.com


"Paul Clement" <UseAdddressA...@swspectrum.com> wrote in message
news:c8glr1t88cpdpl9kh...@4ax.com...


> ¤ connstr = "Provider = VFPOLEDB;Data Source=" & "C:\ESS2001\DATA\"
> What is the name of your database? I don't see it in the connection
> string.

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

EricLun

unread,
Jan 3, 2006, 11:13:02 PM1/3/06
to
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/details.aspx?FamilyID=e1a87d8f-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

unread,
Jan 3, 2006, 11:46:45 PM1/3/06
to
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.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_wi...@msn.com www.cindywinegarden.com


"EricLun" <eric_...@hotmail.com> wrote in message

news:AFACE1BA-1D55-43B2...@microsoft.com...

EricLun

unread,
Jan 4, 2006, 12:19:04 AM1/4/06
to
I got it! Thank you very much
--
EricLun

Paul Clement

unread,
Jan 4, 2006, 9:44:04 AM1/4/06
to
On Tue, 3 Jan 2006 14:17:18 -0500, "Cindy Winegarden" <cindy_wi...@msn.com> wrote:

¤ 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. ;-)

0 new messages