0

Updating MS Excel. OldeDbException: No value given for one or more required parameters. What is wrong in the below code,

private string _connString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\\Workspace\\TestSet.xls;Mode=Share Deny None;Extended Properties=\"Excel 12.0;HDR=YES;READONLY=FALSE\"";

OpenConnection();
using (OleDbCommand objConfigCmdUpdate = new OleDbCommand("UPDATE [Config$] SET Enabled='1' WHERE TestSuite='CFTS'", ExlConn))
{
     objConfigCmdUpdate.ExecuteNonQuery();
     CloseConnection();
}

What is wrong in this code?

Sharan
  • 1
  • 1
  • 3

1 Answers1

0

If you use HDR=NO the column names are F1, F2 F3 etc...... so your query shlould be

"UPDATE [Config$] SET F1='1' WHERE F2='CFTS'"

for your ref click here

Community
  • 1
  • 1
Dhaval Patel
  • 7,471
  • 6
  • 37
  • 70
  • I dont to keep my code with respect to cell number, I want it to be column specific. Please suggest. – Sharan Jun 13 '14 at 06:00
  • Dhaval, even this did not work. i tried the below command, `using (OleDbCommand objConfigCmdUpdate = new OleDbCommand("UPDATE [Config$] SET B4='1' WHERE A4='CFTS';", ExlConn))` – Sharan Jun 13 '14 at 09:18