Reputation: 3252
As I am working on windows .Net Windows form application, I want to know that can we use DBF (a FoxPro OR Dbase database file
) in .Net Windows form application ?
I want to use DBF
as the back-end database for my winform .Net application.
Please let me know if you have any ideas/solution on it.
Thanks in advance.
Upvotes: 1
Views: 2233
Reputation: 48169
Additionally to the above, since .DBF files are also associated with Visual FoxPro applications, you can easily hook up with VFP's OleDB provider instead of ODBC.
Upvotes: 1
Reputation:
Use ODBC class to access DBF files. Look at connectionstrings.com to find out the right connection string. It should be the following:
string dbfDirectory = @"C:\the_path_to_my_dbf_file_or_files";
using (OdbcConnection conn = new OdbcConnection(@"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" + dbfDirectory + ";"))
{
conn.Open();
using (OdbcCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT * FROM myDbFileFromTheUpperDirectory.dbf";
using (OdbcDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
// do something
}
}
}
}
Upvotes: 3
Reputation: 499142
According to connectionstrings.com, there are several ways to connect to a DBF.
Simply use the correct connection string, and you should be fine.
Upvotes: 3
Reputation: 11903
If you have an OLE DB (preferred) or ODBC driver for it, then yes, absolutely.
Upvotes: 1