Dim user As String
Dim pass As String
Dim srvName As String
Dim dbName As String
Dim Query As String
Dim oSQLServer As SQLDMO.SQLServer
Dim oDatabase As SQLDMO.Database
Dim oTheResults As SQLDMO.QueryResults
Private Sub Form_Load()
user = Form1.Text1
pass = Form1.Text2
srvName = Form1.Text3
dbName = Form1.Text4
Set oSQLServer = New SQLDMO.SQLServer
oSQLServer.LoginTimeout = 10
oSQLServer.ODBCPrefix = False
oSQLServer.Connect srvName, user, pass
Set oDatabase = oSQLServer.Databases(dbName)
Query = "select * from Trigins"
Set oTheResults = oDatabase.ExecuteWithResults(Query)
....
End Sub
|