简体   繁体   中英

OleDbException: No value given for one or more required parameters. Update Query. Excel C#

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM