HI I have created a connection between C# application and MS ACCESS databse but when I am compiling it the error message ia displayed that file db1.mdb not found, please help me to figure out the solution?
This is my code:
This is my code:
Code:
using System; using System.Data.OleDb; class OleDbTest{ public static void Main() { OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\db1.mdb"); OleDbCommand aCommand = new OleDbCommand("select * from emp_test", aConnection); try { aConnection.Open(); OleDbDataReader aReader = aCommand.ExecuteReader(); Console.WriteLine("This is the returned data from emp_test table"); while(aReader.Read()) { Console.WriteLine(aReader.GetInt32(0).ToString()); } aReader.Close(); aConnection.Close(); } catch(OleDbException e) { Console.WriteLine("Error: {0}", e.Errors[0].Message); } } }
Comment