0
Reply

Exception error while updating Excel C#

Ask a question
tommy

tommy

15y
2k
1
try  
            {     
                string connectionString = @"provider=Microsoft.Jet.OLEDB.4.0;data 
 
source=C:\Documents and Settings\choogl\Desktop\workbooktest.xls;Extended 
Properties=""Excel 8.0;HDR=NO;IMEX=1;""";  
                OleDbConnection conn = new OleDbConnection(connectionString);  
                OleDbCommand cmdupdate = new OleDbCommand();  
                cmdupdate.Connection = conn;  
                cmdupdate.CommandText = "UPDATE [location$] SET name ='park'
 WHERE ID ='1'"
;  
                conn.Open();  
                cmdupdate.ExecuteNonQuery();  
                conn.Close();  
            }  
            catch (Exception e)  
            {  
                MessageBox.Show(e.ToString());  
            } 

 

Hi I'm trying to update a excel sheet but whenever I Debug the code this exception error pop's up:
"System.Data.OleDb.OleDbException: No value given for one or more required parameters."

Can anyone help?