I want to insert data from my application to existing excel file.When I try I get error message
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

SenthilkumarPosted Apr 29, 2012, 4:23 AM
There is an example talks about the same.
Please refer this article
http://csharp.net-informations.com/excel/csharp-excel-oledb-update.htm