Connecting to .DBF file????
-
-
Can anyone tell me how to connect to fox database (dbf file) from C#? I tried to use odbcDataAdapter but I could not access data in my dbf file. Maybe i did something wrong or is there any other normal way how to retrieve data from dbf file? thanx a lot...
Here's how we do it using an OleDB provider for VFP:
using System.Data.OleDB; private void FillDataSet() { OleDbConnection foxConn = new OleDbConnection( "Provider=VFPOLEDB.1;Data Source=C:\\DataDirectory"); OleDbCommand foxCommand = new OleDbCommand(); OleDbDataAdapter foxDA = new OleDbDataAdapter(); DataSet foxData = new DataSet(); foxCommand.Connection = foxConn; foxCommand.CommandType = CommandType.Text; foxCommand.CommandText = "SELECT * FROM myTable"; foxDA.SelectCommand = foxCommand; foxDA.Fill(foxData, "MyTable"); }