Dim northWindDbConnection As New System.Data.OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\NWind.mdb")
Dim dataSet As New DataSet()
northWindDbConnection.Open()
Try
Dim customersSelectCommand As New System.Data.OleDb.OleDbCommand( _
"SELECT $$*$$ FROM Customers", northWindDbConnection)
Dim customersReader As System.Data.OleDb.OleDbDataReader = _
customersSelectCommand.ExecuteReader()
' データベースの顧客テーブルからすべてのデータをロードします。
Dim customersTable As New DataTable("Customers")
customersTable.Load(customersReader)
' 顧客データ テーブルをデータ セットに追加します。
dataSet.Tables.Add(customersTable)
Dim ordersSelectCommand As New System.Data.OleDb.OleDbCommand( _
"SELECT $$*$$ FROM Orders", northWindDbConnection)
Dim ordersReader As System.Data.OleDb.OleDbDataReader = _
ordersSelectCommand.ExecuteReader()
' データベースの顧客注文からすべてのデータをロードします。
Dim ordersTable As New DataTable("Orders")
ordersTable.Load(ordersReader)
' 注文データ テーブルをデータ セットに追加します。
dataSet.Tables.Add(ordersTable)
Finally
northWindDbConnection.Close()
End Try