BUG: Property Change Through Collection Is Not EffectiveID: Q192644
|
Setting the properties of a connection's existing Connectstring, and using the Properties collection prior to connecting may not update the connection string used by the connection object to connect to the database.
If the connection string specifies a property that is set through the Properties collection, the connection string takes precedence.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
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>;"
'If "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 "; .Properties ("Current Catalog")
'Open the connection.
.Open UserID:="sa"
'Check the database that was opened, is it the one you wanted ?
Debug.Print " Catalog is "; .Properties ("Initial Catalog")
End with
Set cn = nothing
http://support.microsoft.com/support/default.asp
Additional query words: kbADO150bug kbADO200bug kbVBp kbADO150 kbADO200 kbSweepNext
Keywords : kbADO150 kbADO150bug kbADO200 kbADO200bug kbVBp kbSweepNext
Version : WINDOWS:1.5,2.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: May 17, 1999