ADO Wrapper Classes | CodeGuru

ADO Wrapper Classes

Environment: VC6 SP4, NT4 SP6 Acknowledgements This article is based in part on Bob Place’s ADO is AOK (a simple ADO tutorial). Wrapper Usage This is consist of 2 classes. CDyndb : This Class manages connections and recordsets. Recordsets are organized as linked list (CList) and you can access them using their ids. CDynRec : […]

Written By
CodeGuru Staff
CodeGuru Staff
Mar 21, 2001
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6 SP4, NT4 SP6

Acknowledgements

This article is based in part on Bob Place’s
ADO is AOK (a simple ADO tutorial).

Wrapper Usage

This is consist of 2 classes.

  • CDyndb : This Class manages connections and recordsets. Recordsets are organized as linked list (CList) and you can access them using their ids.
  • CDynRec : This class is the node to populate for each recordsets.

Simply follow these steps in order to use the ADO wrapper classes:

  1. You need to add the following line stdafx.h :
  2. #import "c:program filescommon filessystemadomsado21.tlb" no_namespace rename ("EOF", "adoEOF")
    
  3. Call the OpenConn function
    theApp.m_dyndb.OpenConn(“driver=sql server;server=dogu;UID=sa;PWD=;database=dbtraining;”);
    Call OpenRec function 
    theApp.m_dyndb.OpenRec("select * from Courses");
    
    Call GetFieldVal function to get the value of the fields. This function returns variant type.
      You can cast it as usual way like “short(variantdata);” 
    vardat=theApp.m_dyndb.GetFieldVal(0,2);
    
    Call GetFieldType to get the type of the field. “en” has a definition like
      DataTypeEnum en; (see MSDN for details)
    en=theApp.m_dyndb.GetFieldType(0,2);
    
    Call GetFieldCount to get the number of the fields that selected in the recordset.
    Call GetFieldName to obtain the name of the field.
    

To iterate through a recordset, you can use the m_pRecordSet member functions MoveXXX.

Advertisement

Downloads

Download source – 2 Kb

Download demo project – 121 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.