Opening a dbf File

C

Ctal

Hi,

I'm having some trouble opening a dbf file in my application. I'm
getting an oledb exception with the error message:

Message @"'C:\Work\comp310.dbf' is not a valid path. Make sure that
the path name is spelled correctly and that you are connected to the
server on which the file resides."

It is a valid path as the variable to the dbf is filled from an
openfile dialog. Here's the relevant code (pathName is
"C:\Work\comp310.dbf" in this case):

string dbfConnString = String.Format
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended
Properties=dBase IV", pathName);

oleDA = new OleDbDataAdapter("Select * From myDBF", dbfConnString);

OpenDBF("myDBF");

private DataSet OpenDBF(string tableName)
{
oleDA.Fill(myDS, tableName);
return myDS;
}

Thanks in advance for any advice
 
C

Cindy Winegarden

Hi!

Please do yourself a favor and use the FoxPro and Visual FoxPro OLE DB data
provider, downloadable from msdn.microsoft.com/vfoxpro/downloads/updates.

Since you're using a "free" table your connection string should point to the
directory where the DBFs reside, not to a particular file name. The simplest
form of connection string looks like "Provider=VFPOLEDB.1;Data
Source=C:\Temp\;" .

Point to the specific table in your Select statement as you've done below.
 

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