ADO Wrapper Classes
Posted
by Dogu Tumerdem
on March 21st, 2001
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.
- You need to add the following line stdafx.h :
- Call the OpenConn function
theApp.m_dyndb.OpenConn("driver=sql server;server=dogu;UID=sa;PWD=;database=dbtraining;"); - Call OpenRec function
- 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);"
- Call GetFieldType to get the type of the field. "en" has a definition like DataTypeEnum en; (see MSDN for details)
- Call GetFieldCount to get the number of the fields that selected in the recordset.
- Call GetFieldName to obtain the name of the field.
#import "c:\program files\common files\system\ado\msado21.tlb" no_namespace rename ("EOF", "adoEOF")
theApp.m_dyndb.OpenRec("select * from Courses");
vardat=theApp.m_dyndb.GetFieldVal(0,2);
en=theApp.m_dyndb.GetFieldType(0,2);
Downloads
Download source - 2 KbDownload demo project - 121 Kb

Comments
This is not working.
Posted by Haranadh on 02/28/2006 04:27amRecordset Navigator and Count
Posted by Legacy on 02/22/2002 12:00amOriginally posted by: Doug Hagerman
ReplyIT Manager
Posted by Legacy on 02/21/2002 12:00amOriginally posted by: Doug Hagerman
ReplyProblem
Posted by Legacy on 04/12/2001 12:00amOriginally posted by: zhouhao
I think the #import will cause problem some times because the .dll or tlb file will be installed somewhere instead of c:\program\common files\... so that you need to recompile your program before you distribute it. Is there any other way to overcome this problem?
ReplyAll Fixed...
Posted by Legacy on 04/10/2001 12:00amOriginally posted by: Dogu Tumerdem
download new version from :
http://freedrive.com
user : dogutumerdem
pass : humankind
dyndb.zip
ReplySome Bugs !
Posted by Legacy on 03/22/2001 12:00amOriginally posted by: Anonymous
After modifying button one to point to my database, table, and sa password, i got the About box's Button1 to display the message box(es) ok. But after i close the About box and then File->Exit the application I get ...
ADOTEST caused an invalid page fault in
module OLEDB32.DLL at 0167:1f9c7567.
Registers:
EAX=00000000 CS=0167 EIP=1f9c7567 EFLGS=00210246
EBX=011b7188 SS=016f ESP=0065fa70 EBP=0065facc
ECX=00000000 DS=016f ESI=00000000 FS=3dbf
EDX=bffc9490 ES=016f EDI=00000000 GS=0000
Bytes at CS:EIP:
8b 77 08 8d 46 04 50 ff 15 08 11 9c 1f ff 46 1c
Stack dump:
00000000 00000000 1f9ce482 bff7438c 00000000 0065facc 011b7188 1f9ce46d 011b0728 1f9ca4b3 00000000 011b0728 00000000 011b0728 011b7188 011b4464
I was ADO curious but not ADO employeed so I haven't spent any time debugging this.
Just an FYI...
Reply