title: Syntax error in update using C# inputting data into an existing row
body: <p>I am having problem with my code with the update query it shows the error syntax error in update statement. I would like to insert in data into an existing row with the columns already created.</p>
  
  <pre><code>private void save_care_Click(object sender, EventArgs e)
  {
          if (textBox2.Text=="")
          {
              //Checking if workorder exist in database
              connection.Open();
              OleDbCommand checkrecord = new OleDbCommand("SELECT COUNT(*) FROM [c# barcode] WHERE ([Workorder] = @workorder)", connection);
              checkrecord.Parameters.AddWithValue("@workorder", textBox2.Text);
  
              int recordexist = (int)checkrecord.ExecuteScalar();
  
              if (recordexist &gt; 0)
              {
                  //add data if it exist
                  string cmdText = "UPDATE [c# barcode] SET ([Close from care],[Name care]) VALUES (@Close, @name) WHERE ([Workorder] = @workorder)";
  
                  using (OleDbCommand cmd = new OleDbCommand(cmdText, connection))
                  {
                      cmd.Parameters.AddWithValue("@workorder", textBox2.Text);
                      cmd.Parameters.AddWithValue("@Close", DateTime.Now.ToString("d/M/yyyy"));
                      cmd.Parameters.AddWithValue("@name", label4.Text);
  
                      cmd.ExecuteNonQuery();
  
                      textBox2.Clear();
                      connection.Close();
                  }
  
                  connection.Close();
              }
              else
              {
                  //inserting workorder if it does not exist
                  string cmdText = "INSERT INTO [c# barcode] ([Workorder], [Close from care], [Name care]) VALUES (@workorder, @Close, @name)";
  
                  using (OleDbCommand cmd = new OleDbCommand(cmdText, connection))
                  {
                      cmd.Parameters.AddWithValue("@workorder", textBox2.Text);
                      cmd.Parameters.AddWithValue("@Close", DateTime.Now.ToString("d/M/yyyy"));
                      cmd.Parameters.AddWithValue("@name", label4.Text);
  
                      if (cmd.ExecuteNonQuery() &gt; 0)
                      {
                          textBox2.Clear();
                          MessageBox.Show("Insert successful, workorder has not been handed over, please check");
                      }
                      else
                      {
                          textBox2.Clear();
                          MessageBox.Show("Please rescan");
                          connection.Close();
                      }
  
                      connection.Close();
                  }
              }
          }
          else
              MessageBox.Show("No data, Please scan workorder");
  }
  </code></pre>
  
  <p>Error is at <code>cmd.ExecuteNonQuery();</code> line.</p>
  
  <p>For example the table in the picture under workorder there is a test4 the update will insert data into the column [Close from care] and [name care] in the test4 row</p>
  
  <p><a href="https://i.stack.imgur.com/HZYXB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HZYXB.png" alt="access table"></a></p>