Opening .DBF file using ADODB
hi,
I am trying to open a Data base File using VB6 ADODB connection. the problem is whenever i try to run i get the error message "Path is not a valid path. Make sure that the path is spelled correctly and that you are connected to the server on which the file resides."
Re: Opening .DBF file using ADODB
We can use several providers to open DBF files usind ADODB. Basic way is to use ODBC data source (DSN or DSNless), there is several samples published on web. But how to open DBF files without ODBC? There are two other OLEDB providers, using which you can work with DBF files. One of them is Microsoft.Jet.OLEDB.
Key property to work with DBF files is "Extended Properties" - there is no much info about this parameter in documentation. This parameter has similar meaning as connect parameter in DAO OpenDatabase method. First work is to open connection to DBASE IV files:
Function OpenDBFConn(Path)
Dim Conn: Set Conn = CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Path & ";" & _
"Extended Properties=""DBASE IV;"";"
Set OpenDBFConn = Conn
End Function
Re: Opening .DBF file using ADODB
Are you sure it's a dBASE III file? A .dbf file could also be a FoxPro table. And FoxPro has grown away from dBASE where the files can now be incompatible with older lowest common denominator dBASE III drivers.
Re: Opening .DBF file using ADODB
You should be able to open the DBF directly with ADO.Net using either of the following connection string templates:
OLE DB:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder;Extended Properties=dBASE IV;User ID=Admin;Password="
ODBC:
"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=c:\mydbpath;"