Name
Source (Recordset Object) —
rsObj
.Source (=
strSource
)
Synopsis
A string value that represents the source for the records in the recordset. This can be the name of a stored procedure or a Command object, a table name, or a SQL statement.
Parameters
-
strSource
A string value that can hold the name of a stored procedure or a Command object, the name of a table in the database, or a simple SQL statement.
Example
In this example, we set the Source property to a simple SQL statement.
<%@ 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" -->
<%
' 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 rsHighSales = _
Server.CreateObject("ADODB.Recordset")
' Set the ActiveConnection property of the recordset.
rsHighSales.ActiveConnection = objDBConn
' If you set the Source property of the Recordset
' object, you do not need to specify a source string
' when you call the Recordset object's Open method.
rsHighSales.Source = _
"SELECT Buyer, Price FROM Sales WHERE Price > 70000"
' Open the recordset. Note the lack of a connection ' object specification. ...
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.