Shared Sub New()
Dim dataSet As New DataSet()
Dim mdbfile As String = "Data\Northwind.mdb"
Dim connString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", mdbfile)
Dim conn As New OleDbConnection(connString)
Dim adapter As New OleDbDataAdapter()
m_adapter = New OleDbDataAdapter()
m_adapter.SelectCommand = New OleDbCommand( "SELECT * FROM Employees;", conn )
m_adapter.Fill( dataSet, "Employees" )
m_employees = dataSet.Tables( "Employees" )
m_adapter = New OleDbDataAdapter()
m_adapter.SelectCommand = New OleDbCommand( "SELECT * FROM Orders;", conn )
m_adapter.Fill( dataSet, "Orders" )
m_orders = dataSet.Tables( "Orders" )
m_adapter = New OleDbDataAdapter()
m_adapter.SelectCommand = New OleDbCommand( "SELECT * FROM [Order Details];", conn )
m_adapter.Fill( dataSet, "Order Details" )
m_orderDetails = dataSet.Tables( "Order Details" )
m_employees.ChildRelations.Add( New DataRelation( "Employee_Orders", m_employees.Columns( "EmployeeID" ), m_orders.Columns( "EmployeeID" ) ) )
m_orders.ChildRelations.Add( New DataRelation( "Order_OrderDetails", m_orders.Columns( "OrderID" ), m_orderDetails.Columns( "OrderID" ) ) )
End Sub
Public Shared Readonly Property Employees As DataTable
Get
Return m_employees
End Get
End Property
Public Shared Readonly Property Orders As DataTable
Get
Return m_orders
End Get
End Property
Private Shared m_employees As DataTable
Private Shared m_orders As DataTable
Private Shared m_orderDetails As DataTable
Private Shared m_adapter As OleDbDataAdapter = Nothing