怎么样检验添加的用户已存在

解决方案 »

  1.   

    rst.open "select * from table where field1='a' and ..."
    if not rst.eof then
    msgbox "有这条记录"
    end if
      

  2.   

    rst.open "select username from userinfo where username='"+trim(text1.text)+"'",cnn
    if not (rst.eof and rst.bof) then
       msgbox "用户存在 "
    end if
      

  3.   

    再或者
    rst.open "select count(*) from userinfo where username='"+trim(text1.text)+"'",cnn
    if rst(0)>0 then msgbox "用户存在 "
      

  4.   

    rs.open "select username from user where username='"+trim(text1.text)+"'",conn
    我写了这一句
    但运行时错误信息“对象变量或with块变量未设置”
      

  5.   

    rs  或者conn  没有定义
      

  6.   

    那是因为你的RST(记录集对象)没有实例化,你声明的时候加个NEW就可以了。
    dim rst as new adodb.recordset
      

  7.   

    rs.Open "select * from use where gusetname='" & Trim(Text1.Text) & "'", conn, adOpenStatic, adLockOptimistic
    错误信息“至少一个参数没有被指定”但是我这里的参数都写上去了呀
      

  8.   

    他前面的gusetname改成这样看看Trim(gusetname)
      也就是把代码改成
    rs.Open "select * from use where Trim(gusetname)='" & Trim(Text1.Text) & "'", conn, adOpenStatic, adLockOptimistic
      

  9.   

    一大堆都是正确答案,还有个就是用rs.Open "select * from use where Trim(gusetname)='" & Trim(Text1.Text) & "'", conn, adOpenStatic, adLockOptimistic
    if rs.recordcount<>0 then
      msgbox"存在用户"
    else
    msgbox"用户不存在"
    end if
      

  10.   

    如果我这样写
    sql="select * from use where Trim(gusetname)='" & Trim(Text1.Text) & "'"
    set rs=conn.exucte(sql)
    那么到把新增的用户添加到表里的时候会提示该表不支持更新,如果是这样要怎么样改才能让它支持呀