Reputation: 731
string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\a.xlsx" + ";Extended Properties='Excel 12.0 Xml;HDR=No'";
OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand("Update [tablenameeee$] SET A1='15'", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
i want to access a specific cell in excel , and change its value . but i got the exception
OleDbException. No value given for one or more required parameters.What is the solution ?
Upvotes: 4
Views: 5528
Reputation: 149
Maybe you need a where clause
Update [tablenameeee$] set [F1] = 15 where [F2] = 3
or if you want to access one specific cell, and you know which cell it is, then Steve's solution will fit like a glove to you.
Upvotes: 0
Reputation: 216243
If you use HDR=NO the column names are F1, F2 F3 etc......
OleDbCommand cmd = new OleDbCommand("Update [tablenameeee$] SET F1='15'", conn);
but I think you should specify a WHERE clause to delimit the affected rows.
Remeber, using OleDb you should not think in terms of Rows/Columns but in terms of Records.
As an alternative, if you know exactly the row/column to update you could use
OleDbCommand cmd = new OleDbCommand("Update [tablenameeee$A1:A1] SET F1='15'", conn);
Upvotes: 3