Share via


Creating an OLE DB Template Provider

To create an OLE DB provider using the OLE DB Templates

  1. Use the ATL COM AppWizard and ATL Object Wizard to create the basic project files.

  2. Modify the code in the Execute method in CMyProviderRS.h. (For an example, see Reading Strings Into an OLE DB Provider.)

  3. Edit the property maps in MyProviderDS.h, MyProviderSess.h, and MyProviderRS.h. The wizard creates property maps that contain all properties that a provider might implement. Go through the property maps and remove or comment out properties your provider does not need to support.

  4. Update the PROVIDER_COLUMN_MAP, which can be found in MyProviderRS.h. (See Storing Strings In the OLE DB Provider for an example.)

  5. When you are ready to test your provider, you can test it by trying to find the provider in a provider enumeration. For examples of test code that finds a provider in an enumeration, look at the and samples or the example in Implementing A Simple Consumer.

  6. Add any additional interfaces you desire. (See Enhancing the Simple Read-Only Provider for an example.)

Note   By default, the wizards generate code that is OLE DB level-0 complaint. To ensure that your application remains level-0 compliant, do not remove any of the wizard-generated interfaces from the code.

To create an OLE DB provider using the OLE DB Templates, begin with the ATL COM AppWizard.

To create an ATL project for an OLE DB provider

  1. From the File menu, choose New. The New dialog box appears.

  2. On the Projects tab, choose ATL COM AppWizard.

  3. Name the project on the Projects tab, then click OK. The ATL COM AppWizard appears.

  4. In the ATL COM AppWizard, choose Dynamic Link Library (DLL) for Server Type.

  5. Click Finish and OK.

  • Next, use the ATL Object Wizard.

To use the ATL Object Wizard for an OLE DB provider

  1. From the Insert menu, choose New ATL Object. The ATL Object Wizard appears.

  2. In the left pane, choose Data Access. The Provider icon appears in the right pane.

  3. Select the Provider icon and click Next. The OLE DB Provider tab appears.

  4. On the OLE DB Provider tab, enter a short name for your provider in the Short Name box (MyProvider, for example). The other name boxes populate according to the name you enter.

  5. Edit the other name boxes, if desired. In addition to the object and file names, you can edit the following:

    • CoClass: The name that COM uses to create the provider.

    • ProgID: The programmatic identifier, a text string that can be used instead of a GUID.

    • Version: Used with the ProgID and CoClass to generate a version-dependent programmatic ID.

  6. Click OK.

The ATL Object Wizard generates the following files. (The exact file names depend on the choices you made on the OLE DB Provider tab.)

File name Description
MyProviderRS.cpp Contains the command helper Execute method and the provider column map.
MyProviderDS.h Implements the data source object. This header file contains the property map for data source properties.
MyProviderRS.h Implements the command and rowset objects. This header file contains the property map for rowset and command properties.
MyProviderSess.h Implements the session object. This header file contains the property map for session properties.
MyProvider.rgs Contains the registered objects generated by the OLE DB Provider wizard.

Back to Using the OLE DB Provider Templates