Public Class Form1
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With Me.DataGridView1
.Columns.Add("name", "Name")
.Columns.Add("ProvinceName", "ProvinceName")
.AllowUserToAddRows = False
.EditMode = DataGridViewEditMode.EditProgrammatically
End With
Dim cn As New OleDb.OleDbConnection
Dim dpt_name As OleDb.OleDbDataAdapter
Dim dpt_ProvinceName As OleDb.OleDbDataAdapter
Dim dt As New DataTable
Dim dt1 As New DataTable
cn.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" & _
Application.StartupPath & "\data.mdb"
cn.Open()
dpt_name = New OleDb.OleDbDataAdapter("SELECT [name] FROM student ORDER BY [name]", cn)
dpt_ProvinceName = New OleDb.OleDbDataAdapter("SELECT [ProvinceName] FROM Table1 ORDER BY [ProvinceName]", cn)
dpt_name.Fill(dt)
dpt_ProvinceName.Fill(dt)
For Each dr As DataRow In dt.Rows
Me.DataGridView1.Rows.Add()
With Me.DataGridView1.Rows(Me.DataGridView1.Rows.Count - 1)
.Cells("name").Value = dr("name")
.Cells("ProvinceName").Value = dr("ProvinceName")
End With
Next
cn.Close()
End Sub
End Class