Answered Syntax error in UPDATE statement.

  • Friday, August 17, 2012 8:21 PM
     
      Has Code
    I am trying to update information in specific excel rows/colums, and I keep getting 

    Syntax error in UPDATE statement.

    here is my code:

    protected void Button2_Click(object sender, EventArgs e)
            {
                using (OleDbConnection conn = new OleDbConnection())
                {
                    conn.ConnectionString = (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\AIRSIGNDMC\wwwroot\Contract.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=NO""");
                    string sql = string.Format("UPDATE sheet.Cells[6, B] = VALUES ('{0}')", TextBox1.Text);
    
                    using (OleDbCommand cmd = new OleDbCommand(sql, conn))
                    {
    
                        try
                        {
                            conn.Open();
                            cmd.ExecuteNonQuery();
                        }
                        
                        finally
                        {
                            conn.Close();
                        }
                        conn.Close();
                    }
                } 
            }
        }
    }

    Thank you!

All Replies