Visual Basic Concepts
In the previous topics, we created an ActiveX DLL containing two classes, MyOSPObject and MyDataSource. In this topic we'll use the MyDataComponent object as a data source for the form that we created in an earlier topic.
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 test the MyData control
Option Explicit
Dim da As New DataAdapter
Dim ds As New MyDataSource
Private Sub Form_Load()
' Set the Object property of the Data Adapter
' to the MyDataSource object
Set da.Object = ds
' Set the DataMember property
DataGrid2.DataMember = App.Path & "\Customer.txt"
' Set the DataSource to the DataAdapter
Set DataGrid2.DataSource = da
End Sub
Note The above code assumes that the Customer.txt file is located in the same directory as your application. If you have the Customer.txt file in a different location, change the path accordingly. A copy of the Customer.txt file is included with the AXData sample application.
Notice that the second DataGrid contains the same data as the first; like the first, you can edit data in the second grid and the changes will be saved. The big difference between the two is that the first DataGrid is bound to a database, but the second DataGrid isn't — it's bound to a text file through the OLE DB Simple Provider interface.
That does it for the data sources example. Of course, you could easily expand on this. For example, you might add methods to the MyOSPObject class to navigate through the records, or perhaps methods that validate content or formatting for a particular field. You can take it as far as you want.
This topic is part of a series that walks you through creating sample ActiveX data sources.
To | See |
Go to the next step | Data Sources Recap |
Start from the beginning | Creating Data Sources |