我在MS Access中有5个带One to Many relationship
的表,我想显示保存在一个Datagridview
中的所有记录。以下代码用于在Datagridview
中填写一个表中的记录
Imports System.Data.OleDb
Public Class DataGridView
Dim CON As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Employee.mdb;")
Private Sub DataGridView_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim SQL As String
SQL = "SELECT * FROM employee"
Dim ADAPTER As New OleDbDataAdapter(SQL, CON)
Dim DT As New DataTable("employee")
ADAPTER.Fill(DT)
DataGridView2.DataSource = DT
Dim SQL1 As String
SQL1 = "SELECT * FROM employee"
Dim ADAPTER1 As New OleDbDataAdapter(SQL1, CON)
Dim CMD1 As New OleDbCommand(SQL1, CON)
CON.Open()
Dim READER As OleDbDataReader = CMD1.ExecuteReader
READER.Read()
CON.Close()
End Sub
End Class
有没有在一个Datagridview
中显示五个表的记录,替换上面的代码?
这是我的表和关系: