title: System.Data.SqlClient.SqlException: Invalid column name source error: cmd.ExecuteNonQuery()
body: <p>I have a webform that performs both SQL insert and update. Each time I click update I get an error</p>
  <blockquote>
  <p>System.Data.SqlClient.SqlException: Invalid column name 'id'</p>
  <p>Source error:<br />
  Line 133:  cmd.ExecuteNonQuery();</p>
  </blockquote>
  <p>Here's my database</p>
  <pre><code>CREATE TABLE [dbo].[Movie] 
  (
      [MovieId] INT         NOT NULL,
      [Title]   VARCHAR(50) NOT NULL,
      [Media]   VARCHAR(50) NOT NULL,
      [Price]   MONEY       NOT NULL,
      [Qtty]    INT         NOT NULL,
      [Genre]   VARCHAR(10) NULL,
  
      PRIMARY KEY CLUSTERED ([MovieId] ASC) 
  );
  </code></pre>
  <p>C# code:</p>
  <pre><code>protected void OnRowUpdating(object sender, EventArgs e)
  {
          string id = txtMovId.Text;
          string title = txtTitle.Text;
          string media = txtMedia.Text;
          string price = txtPrice.Text;
          string qtty = txtQtty.Text;
          string genre = txtGenre.Text;
  
          string query = &quot;UPDATE Movie SET id = @MovieId, title = @Title, media = @Media, price = @Price, qtty = @Qtty, genre = @Genre WHERE id = @MovieId&quot;;
          string constr = ConfigurationManager.ConnectionStrings[&quot;ConnectionString&quot;].ConnectionString;
  
          using (SqlConnection con = new SqlConnection(constr))
          {
              using (SqlCommand cmd = new SqlCommand(query))
              {
                  cmd.Parameters.AddWithValue(&quot;@MovieId&quot;, id);
                  cmd.Parameters.AddWithValue(&quot;@Title&quot;, title);
                  cmd.Parameters.AddWithValue(&quot;@Media&quot;, media);
                  cmd.Parameters.AddWithValue(&quot;@Price&quot;, price);
                  cmd.Parameters.AddWithValue(&quot;@Qtty&quot;, qtty);
                  cmd.Parameters.AddWithValue(&quot;@Genre&quot;, genre);
  
                  cmd.Connection = con;
                  con.Open();
                  cmd.ExecuteNonQuery();
                  con.Close();
  
                  lblUpdateMsg.Visible = true;
              }
          }
  
          BindGrid();
          Response.Redirect(Request.Url.AbsoluteUri);
      }
  </code></pre>