MDAC 2.5 SDK - OLE DB Providers
OSP Toolkit


 

Connecting to a Simple Provider Using ADO

ADO, as an OLE DB consumer, makes requests to a provider to access data sources and retrieve the desired information. In ADO, you supply the name of the provider either as part of a connection string or in the Provider property of the Connection object. The steps to make the connection depend on whether your OSP is registered as a full OLE DB provider.

To make a connection if your OSP is registered as a full OLE DB provider

  1. Supply the ProgID of your OSP—in this case, SampleOSP_VB—as a parameter to the Provider property of the ADO Connection object. For more information about registering your provider, see "Full Registration."

  2. Open the connection.

  3. Set the Recordset object's source to the Data Member of your provider's data source object.

    The corresponding code follows:

        con.Provider = "SampleOSP_VB"
        con.Open
        rs.Open " C:\Platform SDK\Samples\DataAccess\Samples\Osp\Customer.txt", con
    

To make a connection if your OSP is not registered as a full OLE DB provider but its data source object is registered

  1. Supply the ProgID of the OLE DB Simple Provider DLL (the mapping layer)—in this case, MSDAOSP—as the Provider property of the ADO Connection object. For more information about registering your provider, see "Registration Without a .reg File."

  2. Supply the name of your OSP's data source object—in this case, SampleOSP_VB.MyDataSource—as the DataSource property of the Properties collection on the ADO recordset object.

  3. Open the connection.

  4. Set the Recordset object's source to the Data Member of your provider's data source object.

    The corresponding code follows:

        con.Provider = "MSDAOSP"
        con.Properties("Data Source") = "SampleOSP_VB.MyDataSource"
        con.Open
        rs.Open " C:\Platform SDK\Samples\DataAccess\Osp\Customer.txt", con