Microsoft KB Archive/272176

= SAMPLE: How to Run Singleton SELECT Queries in Visual C++ =

Article ID: 272176

Article Last Modified on 8/5/2004

-

APPLIES TO


 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.7
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition
 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q272176



SUMMARY
STonSel.exe demonstrates how to configure an ADO 2.6 client to retrieve one row of data from a SQL Server 2000 database.



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

STonSel.exe

Release Date: 9-29-2000

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The STonSel.exe file contains the following files:

The ADO Record object in ADO 2.6 has been enhanced to support the retrieval of a single Record. The data obtained is read-only. In case the query results in more than one record, only the first record encountered is returned. The sample performs the following to retrieve one single record:   Sets up a connection to a SQL Server 2000 database: _bstr_t m_Conn(&quot;PROVIDER=SQLOLEDB.1;SQL2000Server=Server;Database=Northwind;uid=sa;pwd=;&quot;); hr = conn->Open(m_Conn,L&quot;&quot;,L&quot;&quot;,-1);   Sets up the ADO Record to contain the query: hr = rec->put_Source(L&quot;SELECT * FROM CUSTOMERS WHERE CUSTOMERID='ALFKI'&quot;);   Opens the Record object by using the adExecuteCommand enumeration: hr = rec->Open(vtEmpty,vtEmpty,adModeReadWrite,adFailIfNotExists, adOpenExecuteCommand,L&quot;&quot;,L&quot;&quot;); 

Steps to Run the Sample

 * 1) Create an empty Win32 console application.
 * 2) Insert STonSel.cpp into the project.
 * 3) Modify the connection string to refer to a valid SQL Server 2000 database.
 * 4) Compile and then run the application.

Keywords: kbinfo kbdownload kbcodesnippet kbfile KB272176

-

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

© Microsoft Corporation. All rights reserved.