In the previous topic, we created a class that implements an OLE DB Simple Provider. In this step we'll create another class that will provide data from the MyOSPObject class to other objects.
Note This topic is part of a series that walks you through creating sample data source components. It begins with the topic Creating Data Sources.
To create the MyDataSource class
Property | Setting |
(Name) | MyDataSource |
DataSourceBehavior | 2-vbOLEDBProvider |
Private Sub Class_GetDataMember(DataMember As String, Data As Object)
' Declare an instance of the MyOSPObject class
Dim MyOSP As New MyOSPObject
' Make sure the DataMember is valid
If DataMember = "" Then
Err.Raise (E_FAIL)
End If
' Set the FilePath property
MyOSP.FilePath = DataMember
' Call the LoadData method to populate the class
MyOSP.LoadData
' Set MyDataSource's data to MyOSPObject's data
Set Data = MyOSP
End Sub
As you may have noticed, this class is much simpler than the MyOSPObject class. In fact, if you go back and compare it with the GetDataMember event, you'll see that it's doing essentially the same thing. The main difference here is that we're using a class that we created rather than the pre-existing ADODB class.
In the next step, we'll convert the form that we created earlier to use our new data source object, and we'll test it to see the results.
This topic is part of a series that walks you through creating sample ActiveX data sources.
To | See |
Go to the next step | Testing the MyData Component |
Start from the beginning | Creating Data Sources |