title: How do I write a specific sql command in C#?
body: <p>I am new to C# and somewhat new to sql commands. I know how to write sql commands directly in the database manager but I haven't been able to figure out how to get it to work as a C# SqlCommand object. Here's an example record of my table:</p>
  
  <pre><code>+----+----------+----------+----------+
  | ID | UserId   | SiteName | Date     |
  +----+----------+----------+----------+
  |  1 | 7698479  | Site1    |  NULL    |
  |  2 | 7698479  | Site2    |  NULL    |
  |  3 | 7698479  | Site3    |  NULL    |
  |  4 | 7698479  | Site4    |  NULL    |
  +----+----------+----------+----------+
  </code></pre>
  
  <p>In my application I have a button. When the user clicks the button, I want the entire Date row associated with a specific user id to update to the current date. "extractedId" is actually a variable in my program that stores the user id. So my question is, what is the correct syntax for this sql command in C#, specifically considering that "extractedId" is a variable? Here is one of the variations of code that I have tried.</p>
  
  <pre><code>SqlCommand myCommand = new SqlCommand("UPDATE myTable SET Date = getdate() WHERE UserId = extractedId", myConnection);
  </code></pre>