大概意思就是按下按扭就弹个对话框告诉我数据库里是不是已经存在这个name了.
excutescalar返回一个object类型,我用的count*返回个数字,我转换一下应该没错的,但是我2个写法都报错..为什么呢            string name=TextBox1.Text;        1:  SqlCommand cmd = new SqlCommand("select count(*) from admin where userName=" + name,conn);
            string result = cmd.ExecuteScalar().ToString();
            if (Convert.ToInt32(result) > 0)        2:  //SqlCommand cmd = new SqlCommand("select count(*) from admin where userName=" + name,conn);
            //int i =Convert.ToInt32(cmd.ExecuteScalar());
            //if (i > 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "startup", "<script>alert('用户名已经存在')</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "startup", "<script>alert('用户名可用')</script>");
            }
        }