Hi!
Iam using VS 2012, MS office 2013, i don't know how to solve this error in c# program?
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: The Microsoft Office Access database engine cannot find the input table or query 'Mobile'. Make sure it exists and that its name is spelled correctly.
Can you help me!
I want to connect the database in access 2013. My code here:
public class Mobile
{
public string MId { set; get; }
public string MName { set; get; }
public string MProducer { set; get; }
public int MProductYear { set; get; }
public float MCost { set; get; }
}
public BindingList<Mobile> GetAll()
{
BindingList<Mobile> list = new BindingList<Mobile>();
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MobileList.accdb;";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();
string sql = "select * from Mobile";
OleDbCommand command = new OleDbCommand(sql, connection);
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
string id = (string)reader["MobileId"];
string name = (string)reader["Name"];
string producer = (string)reader["Producer"];
int productYear = (int)reader["Production year"];
float cost = (float)reader["Cost"];
list.Add(new Mobile() { MId = id, MName = name, MProducer = producer, MProductYear = productYear, MCost = cost });
}
connection.Close();
}
return list;
}
Error in OleDbDataReader reader = command.ExecuteReader(); when i debug
And i had created new database many times