ActiveX Data Objects

Reusing a connection across pages with Session state

<% If IsObject(Session("SessionConnection")) Then Set Connection = Session("SessionConnection") %> Using the Cached Session connection

<% Else Set Connection = Server.CreateObject("ADODB.Connection") Set Session("SessionConnection") = Connection Connection.Open "ADOSamples" %> Opening the Connection

<% End If %> <% SQL = "SELECT ProductName, ProductDescription FROM Products WHERE ProductType in ('Boot', 'Tent')" Set RS = Connection.Execute(SQL) %> Here are the results from the query:
<%= SQL %>

<% Do While Not RS.EOF %> <% RS.MoveNext Loop RS.Close %>
<%= RS("ProductName") %><%= RS("ProductDescription") %>