有没有办法可以用数据库中有关系的记录填充Datagridview
?我想在一个Datagridview
中显示所有记录。我搜索了Google
但我找不到任何解决方案或示例代码。这是我的代码:
Dim sql As String
sql = "SELECT * FROM employee"
Dim adapter As New OleDbDataAdapter(sql, con1)
Dim dt As New DataTable("employee")
adapter.Fill(dt)
' Assigns our DataSource on the DataGridView
DataGridView1.DataSource = dt
'
Dim sql1 As String
sql1 = "SELECT * FROM employee"
Dim adapter1 As New OleDbDataAdapter(sql1, con1)
Dim cmd1 As New OleDbCommand(sql1, con1)
con1.Open()
Dim myreader As OleDbDataReader = cmd1.ExecuteReader
myreader.Read()
con1.Close()