Name

Close (Connection Object, Recordset Object) — Obj .Close

Synopsis

Connection.Close closes the connection to the underlying data provider; Recordset.Close closes a recordset. Both versions of the Close method release system resources used to hold the object variables, but do not remove the object from memory. The same object can be opened later without being instantiated again using the Server object's CreateObject method.

Parameters

Obj

The name of the Connection or Recordset you wish to close.

Example

<%@ LANGUAGE="VBSCRIPT" %>
<% Response.Buffer = True %>
<HTML>
<HEAD>
<TITLE>ADO Examples</TITLE>
</HEAD>
<BODY>
<%
' Include ADOVBS.INC so we can use the ADO constants.
%>
<!-- #include virtual = "/MySSIncludes/adovbs.inc" -->
<%
Dim astrFieldNames( )
Dim astrFieldValues( )

' Instantiate an ADO Connection object.
Set objDBConn = Server.CreateObject("ADODB.Connection") 

' Construct the connection string for the Connection object.
strConn = _
   "driver={SQL Server};;uid=sa;pwd=;database=SalesDB"

' Using the connection string, open the connection.
objDBConn.Open strConn

' Instantiate an ADO Recordset object.
Set rsSales       = _
   Server.CreateObject("ADODB.Recordset")

' Open the Sales table.
rsSales.Open "Sales", objDBConn, , , adCmdTable

' Close the Recordset and Connection - in that order! rsSales.Close objDBConn.Close ' The objects still reside in memory here. ' To release the memory consumed by objects, we must ' set the object variables to the keyword Nothing. Set rsSales = Nothing ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.