Private Sub frmSearchRecords_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cmd As New MySqlCommand
Dim dr As MySqlDataReader
cmd.Connection = con
connect()
cmd.CommandText = "select * from tblconsumer order by ConsumerID"
dr = cmd.ExecuteReader
While dr.Read
With grdView
.Rows.Add()
.Rows(.RowCount - 1).Cells(0).Value = dr(0).ToString
.Rows(.RowCount - 1).Cells(1).Value = dr(1).ToString
.Rows(.RowCount - 1).Cells(2).Value = dr(2).ToString
.Rows(.RowCount - 1).Cells(3).Value = dr(3).ToString
.Rows(.RowCount - 1).Cells(4).Value = dr(4).ToString
.Rows(.RowCount - 1).Cells(5).Value = dr(5).ToString
.Rows(.RowCount - 1).Cells(6).Value = dr(6).ToString
End With
End While
disconnect()
End Sub
谁能帮我解决这个问题,我在数据库中有这个gridview,我无法在这个gridview中加载数据库中的记录