title: SQL Error Must declare the scalar variable
body: <pre><code>        private void FillInvoiceList()
      {
          DataTable distinctInvoice = new DataTable();
          using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["APOS_CONNECTION_STRING"].ConnectionString))
          {
              conn.Open();
              SqlCommand cmd = new SqlCommand("Select distinct svc_tag from data where rep_name = @value");
              cmd.Parameters.AddWithValue("@value", this.DropDownList1.SelectedItem.Text);
              SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(cmd.CommandText, conn.ConnectionString);
              sqlDataAdapter.Fill(distinctInvoice);
          }
          foreach (DataRow row in distinctInvoice.Rows)
          {
              this.ListBox1.Items.Add(row["svc_tag_dim_invoice_num"].ToString());
          }
      }
  </code></pre>
  
  <p>I have this code and I get this error when I call the Fill(DistinctInvoice)</p>
  
  <p>Must declare the scalar variable "@value"</p>
  
  <p>My FillInvoiceList() Method is being called from a SelectedIndexChanged event from the DropDownList1.  The value of DropDownList1.SelectedItem.Text seems to be correct. </p>
  
  <p>Thanks for any help. </p>