' code snippets to accompany Rob Macdonald's ' January 2000 VBD feature A Dip in the Pool ' project requires ADO 2.1 ' Private Sub cmdDoSomething_Click() Dim rs As New Recordset Dim dTime As Double rs.Open "select * from Authors", "Pubs" dTime = Timer Do Loop Until Timer - dTime > 8 rs.Close End Sub 'snippet 2 Dim cn As Connection Private Sub Form_Load() Set cn = New Connection cn.Open "Pubs" End Sub Private Sub cmdDoSomething_Click() Dim rs As New Recordset Dim dTime As Double rs.Open "select * from Authors", cn dTime = Timer Do Loop Until Timer - dTime > 8 rs.Close End Sub 'Snippet 3 To make pooling work we have to apply 'Rob's Rule Number 1 of OLE DB Session Pooling: Dim cn As Connection Private Sub cmdDoSomething_Click() Dim rs As New Recordset Dim dTime As Double rs.Open "select * from Authors", "Pubs" dTime = Timer Do Loop Until Timer - dTime > 8 rs.Close End Sub Private Sub Form_Load() Set cn = New Connection cn.Open "Pubs" cn.Close End Sub ' if you're running MTS <% set rs = Server.CreateObject("ADODB.RecordSet") rs.Open "select * from Authors", "DSN=Pubs;" Response.Write "
" rs.MoveFirst while not rs.EOF Response.Write rs("au_fname") & " " & _ rs("au_lname") & "
" rs.MoveNext wend rs.Close %> ' optional statement Set Session("rs") = rs 'last code snippet rs.Open "select * from Authors", "DSN=Pubs;OLE DB Services=-2"