Creating an OLE DB Template Provider
To create an OLE DB provider using the OLE DB Templates
Use the ATL COM AppWizard and ATL Object Wizard to create the basic project files.
Modify the code in the Execute method in CMyProviderRS.h. (For an example, see Reading Strings Into an OLE DB Provider.)
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.
Update the PROVIDER_COLUMN_MAP, which can be found in MyProviderRS.h. (See Storing Strings In the OLE DB Provider for an example.)
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.
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
From the File menu, choose New. The New dialog box appears.
On the Projects tab, choose ATL COM AppWizard.
Name the project on the Projects tab, then click OK. The ATL COM AppWizard appears.
In the ATL COM AppWizard, choose Dynamic Link Library (DLL) for Server Type.
Click Finish and OK.
- Next, use the ATL Object Wizard.
To use the ATL Object Wizard for an OLE DB provider
From the Insert menu, choose New ATL Object. The ATL Object Wizard appears.
In the left pane, choose Data Access. The Provider icon appears in the right pane.
Select the Provider icon and click Next. The OLE DB Provider tab appears.
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.
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.
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. |