一个注册功能
怎么能判断出注册的名字在数据库中存在!!!!

解决方案 »

  1.   

    使用SQL语句从数据库中查找当前当前名城的记录是否存在。
    也可以对记录进行缓存,然后建立一个合理的数据结构,在内存中处理。
    用然后用ajax异步调用此方法。
      

  2.   

    SELECT COUNT(0) FROM 你的用户表 WHERE 用户名 = 用户输入的字串.replace(''','''')然后判断是否 dr.Read()google一下吧,大神会告诉你天上的星星有很多很多.
      

  3.   


    select count(id) from table where name = @name
    if (return value == 0)
    {
        //todo:name doesn't exist
    }
    else
    {
        // already be used name
    }
      

  4.   

    select count(*) from UerInfo wherename="name"
    获得返回的结果,是0就是不存在,是1就存在
      

  5.   

    注册是  写上一个sql查询 判断下 string strname=txtname.text.trim();
    string  sqlstr=“select count(id) from table where name=‘“+strname+”’”;if(sqlstr==true)
    {
        就是有了 
    }
    else
    {
       没有可以注册
    }
      

  6.   

    select count(*) from table
    where username='注册的名字'
    如果返回0,则数据库中不存在注册的名字;
    如果返回1,则数据库中已存在要注册的名字。
      

  7.   

    你可以select 判断一下时候有结果返回
      

  8.   

    if not exists(SELECT * FROM 用户表 WHERE UserName=@UserName)
    INSERT INTO 用户表 VALUES()@UserName就是传入的注册名
      

  9.   

    ajax异步获取数据,查询用户数据 
    <script type="text/javascript"> 
        var xmlHttp; 
        function createXMLHttpRequest() 
        { 
            if(window.ActiveXObject) 
            { 
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
            } 
            else if(window.XMLHttpRequest) 
            { 
                xmlHttp = new XMLHttpRequest(); 
            } 
        } 
        function CheckUserName() 
        { 
          var us=document.getElementById("txtname").value; 
          if(us!="") 
          { 
            createXMLHttpRequest(); 
            var url= "RegistValidate.ashx?username="+escape(document.getElementById("txtname").value); 
            xmlHttp.open("GET",url,true); 
            xmlHttp.onreadystatechange=ShowResult; 
            xmlHttp.send(null); 
            } 
        } 
        function ShowResult() 
        { 
            if(xmlHttp.readyState==4) 
            { 
                if(xmlHttp.status==200) 
                { 
                    var s; 
                    s=xmlHttp.responseText; 
                      alert(s); 
                } 
            } 
        } 
    </script>
    string sql = "select count(*) from [user] where username = '"+username.Text+"'"; 
    int count = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.Conn, CommandType.Text, sql)); 
    if (count > 0) 
        flag = true;'存在 
    else 
        flag = false;'不存在
      

  10.   

    这个是以前做的 还可以
    http://blog.csdn.net/liaoyukun111/archive/2009/09/24/4589366.aspx
      

  11.   

    异步检查用户名是否存在http://topic.csdn.net/u/20100122/17/2fd20620-322b-4910-ad35-3b3173b651a9.html
    检查的关键是执行SQL查询语句,楼上都贴了
      

  12.   

    可以用ajax异步获取数据,查询用户数据 ,也可以直接到数据库里去查
      

  13.   

    输入的用户名作为数据库查询 的条件这样来写SQL语句,能查出来就存在,不能查出来就不存在
      

  14.   

    if not exists( select * from User where UserName = '新输入的用户' )
    return true
    else
    return false
      

  15.   

    这样的问题也值40啊。没有哪个做数据库关联程序的会不知道答案的说,无论PHP,JAVA,VB.....
      

  16.   

    存储过程中:if not exists( select id from User where UserName = '新输入的用户''insert intoelse
    '啥也不做
      

  17.   

    /// <summary>
    /// Does this user exist?
    /// </summary>
    /// <param name="name">user name(string)</param>
    /// <returns>return bool value</returns>
    public static bool IsExist(string name)
    {
    strSQL = "Select companyID from company Where Name='"
    + name + "'"; try
    {
    ExecuteSqlValue(strSQL);
    return true;
    }
    catch
    {
    return false;
    } }
      

  18.   

    用membership吧,很方便的,这个类有一个方法可以检测用户的存在