How to use ODBC in an ActiveX control by using Visual C++

Article translations Article translations
Article ID: 152534 - View products that this article applies to.
This article was previously published under Q152534
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

SUMMARY

DBCTL demonstrates a way to use ODBC in an ActiveX Control (OLE Control). A Visual C++ and a Visual Basic client application are included as part of this sample. The Visual C++ client is called DBUSR, the Visual Basic client is called DBVBUSR.

The following file is available for download from the Microsoft Download Center:
Dbctl.exe
For more 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 prevent any unauthorized changes to the file.

Notes
  • Use the -d option when running DBCTL.EXE to decompress the file and recreate the proper directory structure.
  • To make the DBCTL sample compile in Microsoft Visual C++ 6.0, you will have to either remove the "_UNICODE" preprocessor directive in the project settings or include the "afxdb.h" header file in DBCtlSet.h.

MORE INFORMATION

DBCTL creates and opens a Class Wizard-configured CRecordset object from within the virtual override of COleControl::OnSetClientSite. The CRecordset- derived object is configured to the COURSE table of the STDREG32.MDB that comes with the sample. Please note that you have to create a user or a system DSN called "student registration" in your ODBC control panel with Access ODBC Driver and have to point this DSN to the STDREG32.MDB file.

The CRecordset-derived object is closed from within its own destructor. The CRecordset object is destructed with a call to the delete operator from within the COleControl derived class destructor.

The control exposes one method, a DisplayRecords method, that simply lists the contents of the recordset in the control.

The OLE Control subclasses a listbox. The string items are added to the listbox by using SendMessage.

The DBUSR.EXE and DBVBUSR.EXE demonstrate using the custom control.

Properties

Article ID: 152534 - Last Review: February 24, 2014 - Revision: 5.0
APPLIES TO
  • Microsoft Foundation Class Library 4.2, when used with:
    • Microsoft Visual C++ 4.0 Standard Edition
    • Microsoft Visual C++ 4.1 Subscription
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
Keywords: 
kbnosurvey kbarchive kbdownload kbdatabase kbprogramming kbfile kbsample KB152534

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com