protected void Button2_Click(object sender, EventArgs e)
    {
        string connstr = System.Configuration.ConfigurationSettings.AppSettings["constr"];
        SqlConnection myconnection = new SqlConnection(connstr);
        myconnection.Open();
        string Comstr = "select count(*) from ST_USERS where (ST_Name='" + TextBox1.Text + "')";
        SqlCommand sqlcmd = new SqlCommand(Comstr, myconnection);
        int n = (int)sqlcmd.ExecuteScalar();
        if (n != 0)
        {
            Response.Write(" <script>alert('该用户名已被占用'); </script>");
        }        else
        {
            Response.Write(" <script>alert('可以使用'); </script>");
        }        myconnection.Close();
        
    }
以上就是想实现那个检测用户是否已被占用的功能,可是运行后什么反应都没有,也没弹出相应的提示!