tommy

tommy

  • NA
  • 32
  • 0

Exception error while updating Excel C#

Jan 15 2009 10:43 PM
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?