ASP.NET C# Must declare the scalar variable
<p>I am trying to populate a GridView using a method called PopulateGrid() (below) but keep getting the same server error "Must Declare the scalar variable "@QUALID". </p>

<pre><code>public void PopulateGrid()
    {
        String val = TextBox2.Text;

        String sql = "SELECT QLEVELNAME FROM Qual_Levels WHERE QUALID=@QUALID";
        SqlCommand cmd = new SqlCommand(sql,
           new SqlConnection(ConfigurationManager.ConnectionStrings["RecruitmentDBConnString"].ConnectionString));

        cmd.Parameters.Add(new SqlParameter("QUALID", val));

        cmd.Connection.Open();


        SqlDataAdapter da = new SqlDataAdapter(sql, cmd.Connection);

        DataSet ds = new DataSet();
        da.Fill(ds, "Qual_Levels");


        SelectionGrid.DataSource = ds;
        SelectionGrid.DataBind();


        ds.Dispose();
        da.Dispose();
        cmd.Connection.Close();
        cmd.Connection.Dispose();
    }
</code></pre>

<p>The GridView is being declared like so..</p>

<pre><code>&lt;asp:GridView ID="SelectionGrid"
            autogeneratecolumns="False" 
            runat="server" CellPadding="4" 
            ForeColor="#333333" GridLines="None" DataKeyNames="QUALID"&gt;

            &lt;Columns&gt;
                &lt;asp:BoundField DataField="QLEVELNAME" HeaderText="Level Name" 
                    ReadOnly="True" SortExpression="name" /&gt;
            &lt;/Columns&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>After trying countless things and trawling through the forums I keep coming up against the same error.</p>

<blockquote>
  <p><strong>Server Error in '/' Application.</strong></p>
  
  <p>Must declare the scalar variable "@QUALID".</p>
  
  <p>Description: An unhandled exception occurred during the execution of
  the current web request. Please review the stack trace for more
  information about the error and where it originated in the code. </p>
  
  <p>Exception Details: System.Data.SqlClient.SqlException: Must declare
  the scalar variable "@QUALID".</p>
  
  <p>Source Error: </p>
  
  <p>Line 282:            DataSet ds = new DataSet();</p>
  
  <p>Line 283:            da.Fill(ds, "Qual_Levels");</p>
</blockquote>

<p>If anyone can shed any light on the situation I would be really grateful! </p>
