你不連接怎麼能用SQL語句??????

解决方案 »

  1.   

    用管理员帐号连接到sql server ,在sysusers中查找用户!
      

  2.   

    dim aa as boolean
    aa=1
    do while aa=0 
        if rs1.state=1 then rs1.close
    select user_name(x)
      

  3.   

    dim aa as boolean
    aa=1
    do while aa=0 
        if rs1.state=1 then rs1.close
    select user_name(x) 
      

  4.   

    dim aa as boolean
    aa=1
    do while aa=1
        if rs1.state=1 then rs1.close
        rs1.open "select user_name(x)"
        if rs1.field(0).value=vbnull then aa=0 else debug.print.rs1.field(0)
    end if
      

  5.   

    Public Sub List_SQLSERVER_User(ByVal Connstr As String, ByVal list As ListBox)
     Dim Cn As New ADODB.Connection
     Dim Rs As New ADODB.Recordset
     Dim sql As String
     sql$ = "select name from sysusers where islogin=1 and isntuser=1 and isntname=1 and uid<>1"
     Cn.Open Connstr$  '联接你的数据库
     Rs.CursorLocation = adUseClient
     Rs.Open sql$, Cn, adOpenForwardOnly, adLockReadOnly
     Rs.MoveFirst
     list.Clear
     While Not Rs.EOF
       list.AddItem Rs("name")
       Rs.MoveNext
     Wend
     Rs.Close: Set Rs = Nothing
     Cn.Close: Set Cn = Nothing
    End Sub