title: Must declare the scalar variable error when inserting a foreign key
body: <p>I am having this problem when I'm trying to insert data into a database with a button and textboxes. Everything works fine except a foreign key that is inside the table throws this error:</p>
  
  <blockquote>
    <p>Must declare the scalar variable "@IDprodajalne"</p>
  </blockquote>
  
  <p>I am getting kind of desperate so I really need your help now.</p>
  
  <pre><code>if (textBoxImeProdajalca.Text != "" &amp;&amp; textBoxPriimekProdajalca.Text != "")
  {
      try
      {
          string query = "insert into Prodajalec values (@IDProadajalne, @ImeProdajalca, @PriimekProdajalca)";
  
          using (connection = new SqlConnection(connectionString)
          using (SqlCommand command = new SqlCommand(query, connection))
          {
              connection.Open();
              command.Parameters.AddWithValue("@IDProdajalne", ComboBoxIDprodajalne.SelectedItem.ToString());
              command.Parameters.AddWithValue("@ImeProdajalca", textBoxImeProdajalca.Text);
              command.Parameters.AddWithValue("@PriimekProdajalca", textBoxPriimekProdajalca.Text);
  
              command.ExecuteNonQuery();
          }
  
          MessageBox.Show("Uspešno dodano");
      }
      catch(Exception ex)
      {
          MessageBox.Show(ex.Message);
      }
  }
  else
  {
      MessageBox.Show("Vnesite vse podatke");
  }
  </code></pre>
  
  <p>And the string declarations </p>
  
  <pre><code>SqlConnection connection;
  string connectionString;
  
  public Form1()
  {
          InitializeComponent();
          connectionString = ConfigurationManager.ConnectionStrings["Naloga.Properties.Settings.ProdajaConnectionString"].ConnectionString;
  }
  </code></pre>