Share via


Microsoft Visual Basic

Important

This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Instead, write a fully functional OLE DB provider using the native OLE DB interfaces.

Information and Guidelines

Following is an outline of the basic steps needed to build an OLE DB Simple Provider in Visual Basic.

To build an OSP in Visual Basic

  1. Start Microsoft Visual Basic. From the File menu, select New Project. The New Project dialog box appears. Use this dialog box to select the ActiveX DLL icon.

  2. From the Project menu, select References. The References dialog box appears, listing the available references. Select the Microsoft OLE DB Simple Provider 1.5 Library check box.

    When you select Object Browser from the View menu or press F2 to display the Object Browser dialog box, the classes OLEDBSimpleProvider and OLEDBSimpleProviderListener should appear in the Classes pane of the Object Browser. You can focus on these classes and their members by selecting MSDAOSP in the Project/Library list.

  3. From the Project menu, select Add Class Module. The Add Class Module dialog box appears. Use this dialog box to select and open the Class Module icon. In the Procedure (Declarations) of the Object (General) inside the Code window, type the following as your first line of code:

    Implements OLEDBSimpleProvider
    
  4. Now you can develop your own simple provider class. Use the OSP Language Reference supplied with the OSP Toolkit to implement all the OSP methods. You can view the sample code in the file MyOSPObject.cls as a reference.

  5. Add a Data Source class and its GetDataMember function. Add a second class to your project, and in its Properties window, select DataSourceBehavior = "1 - vbDataSource". In the Object drop-down box, select Class. In the Procedure drop-down box, select GetDataMember. Implement the GetDataMember by using the DataMember input argument to determine a simple provider object to return. For example:

    Private Sub Class_GetDataMember(Datamember As String, Data As Object)
       Dim MyOSP As New MyOSPObject
       Set Data = MyOSP
    End Sub
    
  6. From the File menu, select Make ProjectName.dll to build and register your provider.

Registration

As part of the information required to register the provider, you need a ProgID for the OSP Data Object.

In Visual Basic, the ProgID is the project name followed by the name of the data source object class or control name on which the OSP Data Object is implemented. The two names are separated with a period.

For example, suppose you have a project named "MyOSPProject" and a class named "MyOSPClass" that implements the msDataSourceObject method. The ProgID will be "MyOSPProject.MyOSPClass". The Version-Independent ProgID will be "MyOSPProject.MyOSPClass.1".