如何实时获取数据库中的行数? (例如,如果我添加/删除一行数据,它将自动显示在提供的文本框中。)
这是我的代码:
Try
connect.Open()
da = New MySqlDataAdapter("Select * from tbl_book_info", connect)
Dim row As String = "Select count(ISBN) from tbl_book_info"
cmd = New MySqlCommand(row, connect)
Dim count As Integer = 0
count = cmd.ExecuteScalar
TextBox7.Text = count
connect.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
da = New MySqlDataAdapter("Select count(ISBN) from tbl_book_info", connect)
da.Fill(data)
但是在上面的代码中,我必须关闭表单并再次打开它,然后将显示更新的行数。预先感谢您的任何帮助。 :)