Can someone shed some light on resource pooling?
I assumed (maybe wrongly! ) that this allowed users to share connections - so when one user has finished with a connection, the connection would be pooled so the next user to ask for a connection with the same details could use the connection without the overhead of creating another connection.
However, in various Microsoft articles they suggest that a connection should always be kept open. Surely this defeats the object.
Microsoft gives an example as follows:
'--------------------------------------------------------
' This will take advantage of resource pooling.
Dim i As Integer
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
Dim c as new ADODB.Connection
c.Open "DSN=LocalServer;UID=sa;PWD=;OLE DB Services=-1"
For i = 1 To 100
Set r = New ADODB.Recordset
r.Open "SELECT * FROM Authors", c
Set r = Nothing
Next I
c.close
Set c = Nothing
'------------------------------------------------------
But says that the followings does not work:
'------------------------------------------------------
' This will not take advantage of resource pooling.
Dim i As Integer
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
For i = 1 To 100
Set c = New ADODB.Connection
Set r = New ADODB.Recordset
c.Open "DSN=LocalServer;UID=sa;PWD=;OLE DB Services=-1"
r.Open "SELECT * FROM Authors", _
"DSN=LocalServer;UID=sa;PWD=;"
r.close
c.close
Set c = Nothing
Set r = Nothing
Next I
'------------------------------------------------------
The first example simply keeps a single connection open at all times and creates multiple recordsets using this connection - surely this cannot be defined as resource pooling!
The second example which is how I would expect resource pooling to work says that this does not work!
Any ideas - please!!!
[sig][/sig]
I assumed (maybe wrongly! ) that this allowed users to share connections - so when one user has finished with a connection, the connection would be pooled so the next user to ask for a connection with the same details could use the connection without the overhead of creating another connection.
However, in various Microsoft articles they suggest that a connection should always be kept open. Surely this defeats the object.
Microsoft gives an example as follows:
'--------------------------------------------------------
' This will take advantage of resource pooling.
Dim i As Integer
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
Dim c as new ADODB.Connection
c.Open "DSN=LocalServer;UID=sa;PWD=;OLE DB Services=-1"
For i = 1 To 100
Set r = New ADODB.Recordset
r.Open "SELECT * FROM Authors", c
Set r = Nothing
Next I
c.close
Set c = Nothing
'------------------------------------------------------
But says that the followings does not work:
'------------------------------------------------------
' This will not take advantage of resource pooling.
Dim i As Integer
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
For i = 1 To 100
Set c = New ADODB.Connection
Set r = New ADODB.Recordset
c.Open "DSN=LocalServer;UID=sa;PWD=;OLE DB Services=-1"
r.Open "SELECT * FROM Authors", _
"DSN=LocalServer;UID=sa;PWD=;"
r.close
c.close
Set c = Nothing
Set r = Nothing
Next I
'------------------------------------------------------
The first example simply keeps a single connection open at all times and creates multiple recordsets using this connection - surely this cannot be defined as resource pooling!
The second example which is how I would expect resource pooling to work says that this does not work!
Any ideas - please!!!
[sig][/sig]