1
Answer

Excel

Ilkin East

Ilkin East

12y
1.2k
1
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
Answers (1)