I have the following program in which i want to insert the values in MS-Access.I am getting the error “the microsoft.ace.oledb.12.0 provider is not registered on the local machine”
I have already installed the database engine as per suggestion of some developers, still i am getting the error.
I am writing the code on Vista machine with VS-2008 and MS-Access-2007.
Please help me to resolve the error
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection con;
OleDbCommand cmd;
private void btnSubmit_Click(object sender, EventArgs e)
{
try
{
con = new OleDbConnection("Provider=Microsft.ACE.Oledb.12.0;Data Source=C:\\Users\\Satish\\Documents\\Testing.accdb");
con.Open();
string cmdText = "Insert Into UserDetail (UsrName,Age,Address,MobileNo) Values ('" + txtName.Text.ToString().Trim() + "','" + txtAge.Text.ToString().Trim() + "','" + txtAddress.Text.ToString().Trim() + "','" + txtMobile.Text.ToString().Trim() + "')";
cmd = new OleDbCommand(cmdText, con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
Try changing the advanced compile configuration to x86.
This is usually because you have a 64bit operating system.
in VS2008
Build -> Configuration Manager -> Active Solution Platform: -> New -> Type or select the new platform -> x86 – > OK
edit:
Try the following:
go to
open
odbcad32.exeif you cannot find excel in the list just click on Add and add it