如何修复SystemInvalidOperationException错误?

时间:2017-03-16 16:43:39

标签: mysql vb.net

我的代码没有错误并且工作正常但是如果表单运行它会弹出一个注释,指出'构造期间从默认实例引用自身的形式导致无限递归。在表单的构造函数中引用使用ME'的表单。我知道这个注释是什么意思,但我的代码是来自CLASS,我如何在类中编写ME.DataGridView1。

以下是代码:

Public Function billing_member_data_grid_radiobutton4_checkchanged()

    MysqlConn.ConnectionString = ServerString
    Dim dbDataSet As New DataTable
    Dim SDA As New MySqlDataAdapter
    Dim bSource As New BindingSource

    Try
        MysqlConn.Open()

        Dim query As String

        query = "SELECT user_memberid as 'Member ID',user_firstname as 'First Name',user_middlename as 'Middle Name',user_lastname as 'Last Name',user_birthday as 'Birthday',user_age as 'Age',user_address as 'Address',user_contact as 'Contact Number',user_gender as 'Gender' FROM gym.user"
        COMMAND = New MySqlCommand(query, MysqlConn)
        SDA.SelectCommand = COMMAND
        SDA.Fill(dbDataSet)
        bSource.DataSource = dbDataSet
        Billing_Member_Data_Grid.DataGridView1.DataSource = bSource
        SDA.Update(dbDataSet)

        MysqlConn.Close()


    Catch ex As Exception
        MsgBox(ex.Message)
    Finally
        MysqlConn.Dispose()



    End Try
    Return True

End Function

1 个答案:

答案 0 :(得分:1)

阅读完毕后,您需要调用READER.Close()。