Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am trying to update single column based on condition in the Excel using Oledb. Am facing issue like "
Operation must use an updateable query
"

Please anyone help in this.

What I have tried:

using (OleDbConnection objConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePath1 + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';"))
            {
                objConn.Open();
                
                OleDbCommand cmd = new OleDbCommand();                

                cmd.Connection = objConn;
                cmd.CommandType = CommandType.Text;

                cmd.CommandText = "UPDATE [Sheet1$] SET [F6]='5' where [F2]='2992269'";
                
                cmd.ExecuteNonQuery();
}
Posted
Updated 22-Jan-21 5:28am
Comments
PIEBALDconsult 22-Jan-21 11:20am    
Maybe try using the column names you provided in the header row?

1 solution

The reason of Operation must use an updateable query error message is this switch: IMEX=1. Remove it and command should start working.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900