July 2000
Intermediate to advanced
492 pages
14h 53m
English
Close (Connection Object, Recordset Object) —
Obj
.Close
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.
Obj
The name of the Connection or Recordset you wish to close.
<%@ 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 ...Read now
Unlock full access