title: Parameter '@stIdCity' was supplied multiple times asp.net c#
body: <p>I am trying to send values to a stored procedure via a listbox containing country names I get them from the database. If I choose one option code works 100% 100%. But if I put 2 or 3 options, I get the following error:</p>
  <blockquote>
  <p>Parameter '@stIdCity' was supplied multiple times.</p>
  <p>Line 322: da.Fill(ds);</p>
  </blockquote>
  <p>Full code:</p>
  <pre><code>protected void lstBoxTestCity_SelectedIndexChanged(object sender, EventArgs e)
  {
      string str = ConfigurationManager.ConnectionStrings[&quot;ConnectionString&quot;].ConnectionString;
  
      using (SqlConnection con = new SqlConnection(str))
      {
          using (SqlCommand cmd = new SqlCommand(&quot;Tprocedure&quot;, con))
          {
              cmd.CommandType = CommandType.StoredProcedure;
  
              foreach (ListItem item in lstBoxTestCity.Items)
              {
                  if (item.Selected)
                  {
                     cmd.Parameters.AddWithValue(&quot;@stIdCity&quot;, item.Value);
                  }
              }
                  
              SqlDataAdapter da = new SqlDataAdapter(cmd);
              DataSet ds = new DataSet();
              da.Fill(ds);
  
              gvProducts.DataSource = ds;
              gvProducts.DataBind();
          }
      }
  }
  </code></pre>
  <p>Stored procedure:</p>
  <pre><code>CREATE PROCEDURE Tprocedure
      (@stIdCity NVARCHAR(20) = NULL, )
  AS
  BEGIN
      SELECT * 
      FROM employees
      INNER JOIN TCity ON employees.IdstICity = TCity.IdstICity 
      WHERE (employees.IdstICity IN (SELECT ITEM 
                                     FROM dbo.SplitString(@stIdCity, ',')) 
         OR ISNULL(@stIdCity, '') = '')
  END
  </code></pre>
  <p>Image of list:</p>
  <p><a href="https://i.stack.imgur.com/LiQt3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LiQt3.png" alt="enter image description here" /></a></p>
  <p>Please help to solve the problem.</p>
  <p>Sorry if the question was repeated, but I could not find a solution to it.</p>