调用系统存储过程sp_helpdb,VB例程(DAO)
Dim r As Recordset,db As Database,wks as Workspace
Set wks = DBEngine.CreateWorkspace("myWks", "Admin", "", dbUseODBC)
Set Db = wks.OpenDatabase("", dbDriverNoPrompt, 0, "ODBC;SERVER=MYSERVER;DRIVER={SQL SERVER};DSN='';UID=sa;DATABASE=master;PWD=;")
Set r = db.OpenRecordset("sp_helpdb")
Do While Not r.EOF
debug.print r!Name
r.MoveNext
Loop
r.Close
db.Close
wks.Close
_________________________________________________________
首先在“工具”-“引用”中引用 Microsoft SQLDMO object Library。
Private Sub Combo1_DropDown()
If Combo1.ListCount > 0 Then
Dim Dn As String
Dn = Trim(Combo2.Text) 'combo1是列数据库名的combo控件
Combo1.Clear
Combo1.Text = Dn
SendKeys "{END}"
'以上实现下拉时原来内容不被清空
Else
End If
Dim svr As New SQLDMO.SQLServer
Dim i As Integer
svr.Connect "ServerName", "UerID", "PWD" '3个引号内分别为服务器名,用户名,密码
For i = 1 To svr.Databases.Count
Combo1.AddItem svr.Databases(i).Name
Next
End Sub
阅读(2261) | 评论(0) | 转发(0) |