title: How to take a value from a database? Must declare the scalar variable "@ID1"
body: <pre><code>  public partial class Form3 : Form
    {       
      string var;
      int ID1;
  
      private void button1_Click(object sender, EventArgs e)
      {
          ID1 = int.Parse(textBox1.Text);
          SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\asp\Desktop\DatabasesPractice\DatabasesPractice\soccer.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
          SqlCommand dataCommand = new SqlCommand("SELECT Name FROM team WHERE ID = @ID1", cn);
  
          cn.Open();
          var = Convert.ToString(dataCommand.ExecuteScalar());
          label3.Text = var;
  
      }
   }
  </code></pre>
  
  <p>It gives me an error saying I must declare the scalar variable <code>@ID</code>, I'm searching everywhere and can't get a solution for my specific case.</p>
  
  <p>Thanks for the help people! your solutions worked :D</p>