Hi,
I want to insert data from my application to existing excel file.When I try I get error message <Operation must use an updateable query>.
My code :
public void button2_Click(object sender, EventArgs e)
{
OleDbConnection con;
OleDbCommand com = new OleDbCommand();
string sql = null;
con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + op.FileName + ";Extended Properties='Excel 12.0 Xml;HDR=YES';");
con.Open();
com.Connection = con;
sql = "Insert into [Sheet1$] (Name,Surname,PC) Values ('Jack','Nana','9')";
com.CommandText = sql;
com.ExecuteNonQuery();
con.Close();
}
Thanks In advance
Excel
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

SenthilkumarRank #387 · 6.5K pointsPosted Apr 29, 2012, 12:23 AM EDT
There is an example talks about the same.
Please refer this article
http://csharp.net-informations.com/excel/csharp-excel-oledb-update.htm