benaround2
Programmer
I was using the following code on a MS Excel 2003 spreadsheet to do initial logon to Microsoft SQL off a user form command box:
Public Sub SQL_Login()
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
With cnn
.Provider = ("SQLOLEDB")
.Properties("Data Source") = "dbserver"
.Properties("Initial Catalog") = "database"
.Properties("Prompt") = adPromptComplete
.Properties("Persist Security Info") = True
.Open
End With
End Sub
I need code to be able to use this setup connection in later SQL queries without a relogin.
Any help is greatly appreciated.
Public Sub SQL_Login()
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
With cnn
.Provider = ("SQLOLEDB")
.Properties("Data Source") = "dbserver"
.Properties("Initial Catalog") = "database"
.Properties("Prompt") = adPromptComplete
.Properties("Persist Security Info") = True
.Open
End With
End Sub
I need code to be able to use this setup connection in later SQL queries without a relogin.
Any help is greatly appreciated.