frothytoad
Technical User
Here is an odd situation. I wrote a piece of code to open a new recordset. Starting with a previously opened connection:
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = ConnString
MyConn.Open
the code to open the recordset looks like this:
Set rst = New ADODB.Recordset
rst.ActiveConnection = MyConn
rst.CursorLocation = adUseClient
rst.CursorType = adOpenKeyset
rst.LockType = LckType
rst.Source = SelectStatement
rst.Open
What surprised me was that I was expecting an error. MyConn is an object, and so I would have expected that I would need, instead of the second line above, a statement like:
SET rst.ActiveConnection = MyConn
But the code ran fine.
Did I just open a new connection using the connection string of MyConn, or did the new recordset truly open using the existing connection? Also, a second question would be: Is there a way to tell within VB which connection is being used?
Thanks...
-- Jeff
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = ConnString
MyConn.Open
the code to open the recordset looks like this:
Set rst = New ADODB.Recordset
rst.ActiveConnection = MyConn
rst.CursorLocation = adUseClient
rst.CursorType = adOpenKeyset
rst.LockType = LckType
rst.Source = SelectStatement
rst.Open
What surprised me was that I was expecting an error. MyConn is an object, and so I would have expected that I would need, instead of the second line above, a statement like:
SET rst.ActiveConnection = MyConn
But the code ran fine.
Did I just open a new connection using the connection string of MyConn, or did the new recordset truly open using the existing connection? Also, a second question would be: Is there a way to tell within VB which connection is being used?
Thanks...
-- Jeff