Microsoft KB Archive/272165

= How To Use a Singleton SELECT from ASP =

Article ID: 272165

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.5 Service Pack 1
 * Microsoft Data Access Components 2.6

-



This article was previously published under Q272165



SUMMARY
This article demonstrates the use of a singleton SELECT to retrieve a single record from the SQL Server IRow interface from ASP.



MORE INFORMATION
A singleton SELECT speeds data retrieval for a resultset that contains one record. The speed increase is a direct result of removing the overhead required for creating the recordset. However, because no recordset is actually created, only one read-only ADODB.Record is returned. This is true regardless of whether the specified SELECT results in multiple records being returned.

If the desired result set contains more than one record, then a normal recordset can be used. Therefore, it is not advisable to issue multiple singleton SELECTs as an alternative to opening a normal ADODB.Recordset in anticipation of retrieving the results faster. The buffering and caching that are set up for a normal ADODB.Recordset speed the performance when you want to retrieve multiple records. <%@ Language=VBScript %>

<%   Dim adoConn     '   As ADODB.Connection Dim adoRec     '   As ADODB.Record Dim sConn      '   As String Dim sQuery     '   As String Dim col        '   As ADODB.Field dim txtResults '   output string for results set adoConn = CreateObject(&quot;ADODB.Connection&quot;) adoConn.ConnectionString = &quot;Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Northwind;uid=sa;pwd=;&quot; adoConn.CursorLocation =  adUseServer adoConn.Open sQuery = &quot;SELECT * FROM CUSTOMERS WHERE CUSTOMERID='ALFKI'&quot;

Set adoRec = CreateObject(&quot;ADODB.Record&quot;)

adoRec.Open sQuery, adoConn, adModeRead, ,adOpenExecuteCommand Response.write(&quot; &quot;)

%>

Keywords: kbhowto KB272165

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.