dim con As New ADODB.Connectiondim connstrf1 As Stringdim rs As New ADODB.Recordset
If rs.State = adStateOpen Then rs.CloseIf con.State = adStateOpen Then con.Closeconnstrf1 = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=数据库;Data Source=IP,1433(端口)"con.ConnectionString = connstrf1con.Opencon.CursorLocation = adUseClient
rs.Open "select ID,用户名,状态 from 表名 ordeR by ID", con, , adLockOptimisticListBox1.ClearDo While Not rs.EOFListBox1.AddItem (rs.Fields("用户名"))rs.MoveNextLoop