how to check the value in text box against the database
<pre><code>protected void btnSubmit_Click(object sender, EventArgs e)
{
    SqlConnection conNwind;
    SqlCommand cmdSelect, cmdInsert;
    SqlDataReader dtrUser;

    string connStr = ConfigurationManager.ConnectionStrings["ConnectionNWind"].ConnectionString;
    conNwind = new SqlConnection(connStr);

    conNwind.Open();

    string select = "Select * from UserRegistration where UserName=@UN AND Email=@Email";
    cmdSelect = new SqlCommand(select, conNwind);

    cmdSelect.Parameters.AddWithValue("@UN", txtUN.Text);
    cmdSelect.Parameters.AddWithValue("@Email", txtEmail.Text);
    dtrUser = cmdSelect.ExecuteReader();


    if (dtrUser.Read())
    {
        if (txtUN.Text != "")
        {
            Label1.Text = "UserName already exists";
        }


        else if (txtEmail.Text != "")
        {
            Label1.Text = "Email already exist!";


        }

        else
        {
            dtrUser.Close();
            string strInsert = "Insert into UserRegistration(FirstName,LastName,UserName,Password,Gender,Address,Email) values(@FN,@LN,@UN,@Pass,@Gender,@Add,@Email)";

            cmdInsert = new SqlCommand(strInsert, conNwind);

            cmdInsert.Parameters.AddWithValue("@FN", txtFN.Text);
            cmdInsert.Parameters.AddWithValue("@LN", txtLN.Text);
            cmdInsert.Parameters.AddWithValue("@UN", txtUN.Text);
            cmdInsert.Parameters.AddWithValue("@Pass", txtPass.Text);
            cmdInsert.Parameters.AddWithValue("@Gender", rdlGender.SelectedItem.ToString());
            cmdInsert.Parameters.AddWithValue("@Add", txtAdd.Text);
            cmdInsert.Parameters.AddWithValue("@Email", txtEmail.Text);

            int intAdd = cmdInsert.ExecuteNonQuery();

            if (intAdd != 0)
                Label1.Text = "User Registration successful,you can now &lt;a href='UserLogin.aspx'&gt;Login&lt;/a&gt;";

            else
                Label1.Text = "Record not added into database!";
        }
    }

    else
        conNwind.Close();

}
</code></pre>

<p>how to check the username and the email address that exist in databese...Pls help!!!</p>
