title: Incorrect syntax near 'achternaam'
body: <p>I am trying to insert a new row into a SQL Server table from a Winforms application. As far as I know my query is correct but Visual Studio keeps returning an error:</p>
  
  <blockquote>
    <p>Incorrect syntax near 'achternaam'</p>
  </blockquote>
  
  <p>I hope that someone can point me in the right direction.</p>
  
  <pre><code>public void UpdateGegevens(int id, string voornaam, string achternaam, string functie, DateTime geboortedatum, decimal uurloon)
  {
  if (ReturnFirstTime(id) == true)
  {
      using (SqlConnection con = new SqlConnection(connectionString))
      {
          using (SqlCommand command = new SqlCommand())
          {
              command.Connection = con;
              command.CommandType = CommandType.Text;
              command.CommandText = "INSERT INTO tbl_Gegevens (Id, voornaam, achternaam, geboortedatum, functie, uurloon) VALUES (@Id, @vn, @an, @gb, @f, @ul);";
  
              command.Parameters.Add("@Id", SqlDbType.Int).Value = id;
              command.Parameters.Add("@vn", SqlDbType.VarChar).Value = voornaam;
              command.Parameters.Add("@an", SqlDbType.VarChar).Value = achternaam;
              command.Parameters.Add("@f", SqlDbType.VarChar).Value = functie;
              command.Parameters.Add("@gb", SqlDbType.Date).Value = geboortedatum;
              command.Parameters.Add("@ul", SqlDbType.Money).Value = uurloon;
  
              try
              {
                  con.Open();
                  command.ExecuteScalar();
              }
              catch (SqlException ex)
              {
                  System.Windows.Forms.MessageBox.Show(ex.Message);
              }
              finally
              {
                  con.Close();
              }
          }
      }
  }
          else
          {
              using (SqlConnection con = new SqlConnection(connectionString))
              {
                  using (SqlCommand command = new SqlCommand())
                  {
                      command.Connection = con;
                      command.CommandType = CommandType.Text;
                      command.CommandText = "UPDATE tbl_Gegevens SET voornaam=@vn achternaam=@an geboortedatum=@gb funtie=@f uurloon=@ul WHERE Id = @Id;";
                      command.Parameters.AddWithValue("@Id", id);
                      command.Parameters.AddWithValue("@vn", voornaam);
                      command.Parameters.AddWithValue("@an", achternaam);
                      command.Parameters.AddWithValue("@gb", geboortedatum);
                      command.Parameters.AddWithValue("@f", functie);
                      command.Parameters.AddWithValue("@ul", uurloon);
                      try
                      {
                          con.Open();
                          command.ExecuteNonQuery();
                      }
                      catch (SqlException ex)
                      {
                          System.Windows.Forms.MessageBox.Show(ex.Message);
                      }
                      finally
                      {
                          con.Close();
                      }
                  }
              }
          }
     }
  </code></pre>
  
  <p>Here is a specification of <code>tbl_Gegevens</code>:</p>
  
  <pre><code>create table [dbo].[tbl_Gegevens] (
     [Id] int not null
   , [voornaam] nvarchar(50) null
   , [achternaam] nvarchar(50) null
   , [geboortedatum] date null
   , [functie] nvarchar(50) null
   , [uurloon] smallmoney null
   , primary key clustered ([Id] asc)
   );
  </code></pre>
  
  <p>I think my dbms is ADO.Net.</p>
  
  <p>This is the way i'm passing the info to the method:</p>
  
  <pre><code>private void btnConfirm_Click(object sender, EventArgs e)
      {
          if (tbName.Text != "" &amp;&amp; tbSurname.Text != "" &amp;&amp; tbFunction.Text
              != "" &amp;&amp; dtpBirthdate.Value != date &amp;&amp; nudSalary.Value != 0)
              {
                  Database1.SetFirstTime(ID);
                  Database1.UpdateGegevens(ID, tbName.Text, tbSurname.Text, tbFunction.Text, dtpBirthdate.Value, nudSalary.Value);
                  this.Hide();
                  frmMain fm = new frmMain(ID);
                  fm.Show();
              }
              else
              {
                  MessageBox.Show("Vul alle velden in!");
              }
          }
  </code></pre>
  
  <p>This is the query i use to get my id:</p>
  
  <pre><code>    public int ReturnLoginID(string username, string password)
      {
          SqlConnection con = new SqlConnection(connectionString);
          SqlCommand cmd = new SqlCommand("Select * from tbl_Login where UserName=@username and Password=@password", con);
          cmd.Parameters.AddWithValue("@username", username);
          cmd.Parameters.AddWithValue("@password", password);
          int ID = 9999;
          con.Open();
          using (SqlDataReader reader = cmd.ExecuteReader())
          {
              reader.Read();
              ID = reader.GetInt32(0);
          }
          con.Close();
          return ID;
      }
  </code></pre>