我有这段代码,我想通过单击更新按钮来显示数据库中的所有数据,但现在它只显示最后一行。我以为 While 会重复自己并发布每一行,但是..是的..谢谢。
Private Sub update_Click(sender As Object, e As EventArgs) Handles update.Click
Dim show_rows As String
Dim Conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\...\mydb.mdb")
Conn.Open()
Dim command As OleDbCommand = New OleDbCommand("SELECT * FROM dreamware_db", Conn)
Dim read As OleDbDataReader = command.ExecuteReader()
If read.HasRows Then
While read.Read()
show_rows = read.Item("text")
post_dreams.Text = "Show:" & show_rows
End While
End If
Conn.Close()
End Sub