就去查下有没有这个用户名啊 
selct cout(*) form table where name=@name
返回数据行数 
为0无数据

解决方案 »

  1.   

    ....就一个sql 语句去查询下有没有同名不就ok了?
      

  2.   

    if (this.txtFaGuanName = "SELECT UserName from LoginTable WHERE UserName=@UserName" == false)
            {
                Response.Write("<script>alert('用户名重复,请更换用户名');windows.open(\"./AddFaGuan.aspx\");</script>");
            }这样肯定不对,但是我这是唯一能想到的
      

  3.   

    protected void UpDateBtn_Click(object sender, EventArgs e)
        {
            CheckUserName(); 
        }    public void CheckUserName()
        {
    sqldatareader read = sqlhelper.executeread(connectionstring,commandtype.text,"SELECT UserName from LoginTable WHERE UserName='"+this.txtFaGuanName.Text.ToString()+"'")
            while(read.read())
                Response.Write("<script>alert('重复用户名,请重新输入用户名');windows.open(\"./AddFaGuan.aspx\");</script>");
        return ;
            }
                TianJiaFaGuan TiJiao3 = new TianJiaFaGuan();
                TiJiao3.UserName = this.txtFaGuanName.Text.Trim();
                TiJiao3.Password = this.txtFaGuanPsw.Text.Trim();
                TiJiao3.LeiBie = this.DropDownList1.SelectedValue.ToString().Trim();            if (TianJiaFaGuanDao.TianJiaFaGuanTable(TiJiao3) == true)
                {
                    Response.Write("<script>alert('添加法官信息成功');window.open(\"./GuanLiPinTai.aspx\");</script>");
                }
                
            }
        }我改了一下,这样做的,好像还有问题,哪位老师给我讲一下可以吗?
      

  4.   

    while(read.read())
    Response.Write("<script>alert('重复用户名,请重新输入用户名');windows.open(\"./AddFaGuan.aspx\");</script>");
    return;
    }》》》if(read.HasRows) {
    Response.Write("<script>alert('重复用户名,请重新输入用户名');windows.open(\"./AddFaGuan.aspx\");</script>");
    return;
    }