Hi Friends,
I want insert some records in excel sheet using c# but it gives error like this
"The 'Microsoft.ACE.OLEDB.16.0' provider is not registered on the local machine"
i am using office 2016 and windos 10 with 64 bit.
and my code is below
string ConStr = "";
//getting the path of the file
string path = Server.MapPath("InsertDataExcel.xlsx");
//connection string for that file which extantion is .xlsx
ConStr = "Provider=Microsoft.ACE.OLEDB.16.0;Data Source=" + path + ";Extended Properties=\"Excel 16.0;ReadOnly=False;HDR=Yes;\"";
//making query
string query = "INSERT INTO [Sheet1$] ([Name], [Email], [MobileNo], [Location], [Qualification]) VALUES('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')";
//Providing connection
OleDbConnection conn = new OleDbConnection(ConStr);
//checking that connection state is closed or not if closed the
//open the connection
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
//create command object
OleDbCommand cmd = new OleDbCommand(query, conn);
int result = cmd.ExecuteNonQuery();
if (result > 0)
{
Response.Write("");
}
else
{
Response.Write("");
}
conn.Close();
So please suggest what am i doing mistake.
Thanks
Leon DPosted Nov 27, 2017, 4:59 AM
Rajkiran SwainPosted Nov 27, 2017, 4:53 AM
Nilesh PatilPosted Nov 27, 2017, 4:41 AM