我无法在网格视图中显示任何数据,它是一个空白数据网格 连接是开放的,一切都很好但数据没有显示!!我是新手
Imports System.Data.OleDb
Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.Open()
Dim dvginfo As DataGridView
Dim table As New DataTable("Address")
Dim da As New OleDbDataAdapter("Select * FROM Address", con)
Dim dtrow As DataTable
da.Fill(table)
If table.Rows.Count = 0 Then
Return
End If
For Each dtrow In table.Rows
dvginfo.Rows.Add()
dvginfo.Rows(dvginfo.RowCount - 1).Cells("colFirstname").Value = dtrow("Firstname").ToString()
dvginfo.Rows(dvginfo.RowCount - 1).Cells("colLastname").Value = dtrow("Lastname").ToString()
dvginfo.Rows(dvginfo.RowCount - 1).Cells("colDOB").Value = Convert.ToDateTime(dtrow("DOB").ToString())
Next
dvginfo.ClearSelection()
con.Close()
End Sub
End Class
答案 0 :(得分:0)
试试这个......
Imports System.Data.OleDb
Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.Open()
Dim dvginfo As DataGridView
Dim table As New DataTable("Address")
Dim da As New OleDbDataAdapter("Select * FROM Address", con)
Dim dtrow As DataTable
da.Fill(table)
dvginfo.DataSource = table
con.Close()
End Sub
End Class