在一个datagridview中显示所有记录

时间:2016-11-09 00:14:35

标签: vb.net datagridview

我在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中显示五个表的记录,替换上面的代码?

这是我的表和关系:

Employee's Record

0 个答案:

没有答案