Article ID: 192644
Article Last Modified on 5/17/2007
Dim cn As New ADODB.Connection
With cn
'Set the initial connection string.
'Following line should be commented to test for the workaround
'in the second test as mentioned in Step 6.
.ConnectionString = "Provider=SQLOLEDB;Data Source=<yourserver>;" &
"Initial Catalog=pubs;"
' Following line has to be uncommented when you are commenting
' the preceding line as mentioned in step 6.
'.ConnectionString = "Provider=SQLOLEDB;Data Source=<yourserver>"
' If Initial Catalog is not set in connection string,
' it works correctly
'Check which is the current catalog.
Debug.Print " Catalog is "; .Properties ("Initial Catalog")
.CursorLocation = adUseClient
'Override connection string with property setting.
.Properties("Initial Catalog") = "NorthWind"
'Check which is the current catalog, has it changed?
Debug.Print " Catalog is "; .Properties ("Initial Catalog")
'Open the connection.
.Open UserID:="sa"
'Check the database that was opened, is it the one you wanted ?
Debug.Print " Catalog "; .Properties ("Current Catalog")
End with
Set cn = nothing
'.ConnectionString = "Provider=SQLOLEDB;Data Source=nuvee;Initial Catalog=pubs;"===============================================================
'.ConnectionString = "Provider=SQLOLEDB;Data Source=nuvee;"===============================================================
Keywords: kbado210sp2fix kbbug kbdatabase kbfix kbfix kbmdacnosweep KB192644