已经有一个与此连接关联的开放DataReader,必须首先关闭vb.net mysql

时间:2014-09-19 00:00:54

标签: mysql vb.net

我有错误

已经有一个与此连接关联的打开的DataReader,必须先关闭它。

这是我的代码。 你能帮我么??? 谢谢

    MySqlConnection = New MySqlConnection
    MySqlConnection.ConnectionString = "server = localhost; port=3307; user id = root; password = 1234; database = mcs;"
    Dim READER As MySqlDataReader


    If cmbxyear.Text = "NURSERY" Then


        MySqlConnection.Open()
        Dim query As String
        query = " select student_no from mcs.fullpayment_nursery where student_no = '" & txtstudent_no.Text & "'"
        Dim Command As New MySqlCommand(query, MySqlConnection)
        READER = Command.ExecuteReader
        If query = txtstudent_no.Text Then

            MessageBox.Show("YOU DON'T HAVE REMAINING BALANCE")
            MySqlConnection.Close()


        Else

            Dim query1 As String
            query1 = " select student_balance from mcs.installmentpayment_nursery where student_no = '" & txtstudent_no.Text & "'"
            Dim Command1 As New MySqlCommand(query1, MySqlConnection)
            READER = Command.ExecuteReader
            READER.Read()
            txtstudentbalance.Text = READER(0)


            MessageBox.Show("Student Balance Generated")
            MySqlConnection.Close()


        End If

0 个答案:

没有答案