dim aa as boolean aa=1 do while aa=0 if rs1.state=1 then rs1.close select user_name(x)
dim aa as boolean aa=1 do while aa=0 if rs1.state=1 then rs1.close select user_name(x)
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
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
aa=1
do while aa=0
if rs1.state=1 then rs1.close
select user_name(x)
aa=1
do while aa=0
if rs1.state=1 then rs1.close
select user_name(x)
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
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