Hello everybody,
I am having problems in connecting dbf file using C#
Actually, what i want to do is as follows:
1. on GO button, the code connects to dbf file saved in my local hdd ie at d:\dbase
2. the file name is billingsample.dbf of type IV
3. the file contains 4 columns, one is account_no and another is a num_poles
4. after connection to the dbf file the code should search the account_no column and print the first row in it at text2.text
here is the code
private void button1_Click(object sender, EventArgs e)
{
String ConnectionString;
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source = D:\\dbase;Extended Properties =dBase IV;";
System.Data.OleDb.OleDbConnection dBaseConnection;
dBaseConnection = new System.Data.OleDb.OleDbConnection(ConnectionString);
dBaseConnection.Open();
System.Data.OleDb.OleDbCommand dBaseCommand;
dBaseCommand = new System.Data.OleDb.OleDbCommand("SELECT ACCOUNT_NO FROM billingsample", dBaseConnection);
System.Data.OleDb.OleDbDataReader dBaseDataReader;
dBaseDataReader = dBaseCommand.ExecuteReader(CommandBehavior.SequentialAccess);
textBox2.Text=dBaseDataReader.GetValue(0).ToString();
}
but the following codes give error
The Microsoft Jet database engine could not find the object 'billingsample'. Make sure the object exists and that you spell its name and the path name correctly
I tried changing the string SELECT ACCOUNT_NO from billingsample to billingsample.dbf or d:\\dbase\\billingsample
but i have no sucess .....:(
Any help wuld be appreciatd