基本上都是用控件绑定的 table(loginname, iD,...)
在输入一个新的数据时到一个文本框时如何判断表中已存在相同的登陆名loginname呢

解决方案 »

  1.   


    select count(loginname) from tablename where loginname=text1.text;
    if recordsetname.fields(0).value>1 then
    ...
    else
    ...
    endif
      

  2.   

    select * from table where loginname='"&text1.text&"'and  iD='"&text2.text&"'
    if rs.RecordCount>0 then 
       '''重复
    end if 
      

  3.   

    我是这么写的 怎么就不行呢?
        Dim sql As String
        Dim rs As New ADODB.Recordset
        sql = "Select * from login where loginName='" & TxtLoginName
        Set rs = TransactSql(sql)
        If rs.EOF = False Then
            MsgBox "登陆名已经存在!", vbOKOnly + vbExclamation, "警告!"
        End If
      

  4.   

    sql = "Select * from login where loginName='" & Trim(TxtLoginName) & "'"