我的代碼沒有錯誤,並且工作正常,但如果表單運行,它會彈出一個註釋,說明「表單在構造過程中會從導致無限遞歸的默認實例引用自身。在表單的構造函數中引用使用ME'的表單。我知道註釋的含義,但是我的代碼來自CLASS,我怎麼才能在類中寫入ME.DataGridView1。如何修復SystemInvalidOperationException錯誤?
下面是代碼:
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
轉** Option Strict On **。實現'使用'。使用**參數**。對你來說只是一些指針。 – Bugs
在您的環境中精心設計'連接這兩個功能' –
爲什麼使用子例程等功能? – TonyW