Running queries, good design here?
<p>Sorry for posting so many nubbin questions on ASP.net, I'm getting the hang of it slowly.</p>

<p>I execute queries on my pages as such (working):</p>

<pre><code>&lt;%@ Import Namespace="System.Data" %&gt;
&lt;%@ Import Namespace="System.Data.SqlClient" %&gt;
&lt;script runat="server"&gt;

    // When the registration form is submitted
    protected void regSubmit(object sender, EventArgs e)
    {
        // No erros so far
        Boolean anyError = false;
        string errorMessages = "";

        // Take all form values
        string username = txtUsername.Text;
        string password1 = txtPassword1.Text;
        string password2 = txtPassword2.Text;
        string emailAdd = txtEmail.Text;

        // Verify that username is unique
        using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDbConn"].ToString()))
        {
            SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM tblUsers WHERE username = '" + username + "'", cn);
            cn.Open();
            SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            rdr.Read();
            int result = int.Parse(rdr[0].ToString()); //read a value
        }


        statusLabel.Text = username;
    }
&lt;/script&gt;
</code></pre>

<p>My question is, is this the best practise, do I have to have a 'using' block and that inner structure for every query I run, or is there a simpler way of doing it?  Also, do I need to close anything off or does the garbage man take care of it?</p>

<p>In Classic ASP I would just have a </p>

<pre><code>adoCon.execute("DELETE FROM TABLE")
</code></pre>

<p>or a </p>

<pre><code>rsCommon.open("SELECT * FROM TABLE"), adoCon
do until rsCommon.EOF

rscommon.movenext
loop
rsCommon.close
</code></pre>

<p>Tallyho!  Thank you for any help!
Which seems a lot simpler and intuitive to me.</p>
