还是问问高人一个问题
   假如我的数据库 是01.mdb
    数据库有表admin 字段 user_name user_pass user_power
 其中user_power为权限类型为数字 假设里面有数据
   admin 123456 1
   guest 123    01是管理员权限 0是访问者权限   我的问题是  在做登陆框的时候 怎么做 当我输入拥护text1.text 为admin时候 text3.text(权限)就为1 自动的~~
  我的分不多了    所以就给20 吧!~~ 希望各位路过的 给个答案!~~~

解决方案 »

  1.   

    数据库连接你会吧,我就不写那些代码了
    Private Sub Text1_LostFocus()'当text1失去焦点
    rs=conn.execute("select user_power from admin where user_name='"&text1.text&"'")
    if not rs.bof and not rs.eof then
    text3.text=rs(0)
    end ifEnd Sub
      

  2.   

    Private   Sub   Text1_LostFocus() '当text1失去焦点
    rs=conn.execute( "select   user_power   from   admin   where   user_name= ' "&text1.text& " ' ")
    if   not   rs.bof   and   not   rs.eof   then
    text3.text=rs(0)
    end   ifEnd   Sub 
      

  3.   

    和我自己做着玩的哪个西哪个木挺象
    Private Sub Text1_LostFocus()
    Dim str As String
    str = Text1.Text
    If str = "" Then
    Text1.Text = "帐号为空重新输入"
    Else
    Call selectusername(str)
    End If
    End Sub
    Public Sub insertname(a As String)
    Open "c:\userdata.txt" For Output As #1
    Write #1, a
    Close #1
    End Sub
    ==============================================
    Private Sub selectusername(str As String)
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sql As String
    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    sql = "select * from userinfo where username='" + str + "'"
    cn.ConnectionString = "Driver={SQL Server};Server=MICROSOFT01;UID=sa;PWD=sa;Database=articlemanaged"
    cn.Open
    Set rs = cn.Execute(sql)
    If rs.EOF = True Or rs.BOF = True Then
    Me.Label3.Caption = "帐号输入错误"
    Text1.Text = ""
    Text2.Enabled = False
    Command2.Enabled = False
    Exit Sub
    End If
    If CStr(rs.Fields(3).Value) = "0" And CStr(rs.Fields(4).Value) = "1" Then
    Me.Label3.Caption = "欢迎管理员登录"
    Text1.Enabled = False
    Command2.Enabled = True
    End If
    If CStr(rs.Fields(3).Value) = "1" Then
    Me.Label3.Caption = "此帐号已登录不允许登录"
    Text2.Enabled = False
    End If
    If CStr(rs.Fields(3).Value) = "0" And CStr(rs.Fields(4).Value) = "0" Then
    Me.Label3.Caption = "欢迎用户登录"
    Text1.Enabled = False
    Command2.Enabled = True
    End If
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing
    End Sub