0

データベースにデータが入力されたときにテキストボックスを更新するにはどうすればよいですか?ここに私のコードがあります....

Imports MySql.Data
Imports MySql.Data.MySqlClient

Public Class Form1
    Dim dbCon As MySqlConnection
    Dim strQuery As String = ""
    Dim SQLCmd As MySqlCommand
    Dim DR As MySqlDataReader

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GetDBData()
    End Sub

    Private Sub GetDBData()
        Try
            dbCon = New MySqlConnection("Server=localhost; Database=mydatabase;Uid=root;Pwd=;")
            strQuery = "SELECT *" & _
                    "FROM tbl_user"

            SQLCmd = New MySqlCommand(strQuery, dbCon)
            dbCon.Open()
            DR = SQLCmd.ExecuteReader

            While DR.Read
                txtData.Text = txtData.Text & DR.Item("CostumerOrder") & Space(10) & DR.Item("OrderPrice") & vbCrLf
            End While

        Catch ex As Exception
            MsgBox("FAIL CONNECT!" & vbCrLf & vbCrLf & ex.Message)
        End Try
    End Sub

    Private Sub txtData_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtData.TextChanged

    End Sub
End Class
4

2 に答える 2

0

それは醜い解決策ですが、これを試すことができます..

While DR.Read
    txtData.Text = txtData.Text & DR.Item("CostumerOrder") & Space(10) & DR.Item("OrderPrice") & vbCrLf
    Application.DoEvents()
End While
于 2013-07-10T15:39:11.223 に答える