{"操作无效,因为它导致对SetCurrentCellAddressCore函数的可重入调用。"}

时间:2017-11-08 00:54:47

标签: vb.net

我对此消息有错误{"操作无效,因为它导致对SetCurrentCellAddressCore函数的可重入调用。"}

当我点击 Form1Main 中的按钮以显示带有上述代码的 FormSearchCompany 时出现错误,然后关闭表单,之后我切换到 FormMain2 ,然后点击按钮调用相同的表单( FormSearchCompany

当我点击 Form1Main 中的按钮以显示带有上述代码的 FormSearchCompany 时出现错误,然后关闭表单,之后我切换到 FormMain2 ,然后点击按钮调用相同的表单( FormSearchCompany

如果你想看到完整的代码在这里

https://github.com/gedeeinstein/Surat-Jalan-PT-Dintara

Sub Data_Perusahaan()
    Proses.CloseConn()

    Try
        Proses.OpenConn()
        SQL = "SELECT tawar01.kode_pelanggan AS 'KODE PERUSAHAAN', " _
            & "pelanggan.nama AS 'NAMA PERUSAHAAN', tawar01.att AS 'PENERIMA', tawar01.kode AS 'PENAWARAN', tawar01.alamat as 'ALAMAT', tawar01.tgl AS 'TGL' " _
            & "FROM tawar01 INNER JOIN pelanggan " _
            & "ON tawar01.kode_pelanggan = pelanggan.kode " _
            & "WHERE pelanggan.nama LIKE '%" & Rep(txtCariPerusahaan.Text) & "%' ORDER BY tawar01.tgl DESC"
        perusahaan = Proses.ExecuteQuery(SQL)
        Try
            Me.DGPerusahaan.DataSource = perusahaan
            'Me.DGPerusahaan.Columns(0).Visible = False
            Me.DGPerusahaan.Columns(0).Width = 100 '**The Error is Here**
            Me.DGPerusahaan.Columns(1).Width = 380
            Me.DGPerusahaan.Columns(2).Width = 180
            Me.DGPerusahaan.Columns(3).Width = 190
            Me.DGPerusahaan.Columns(4).Visible = False
            Me.DGPerusahaan.Columns(5).Visible = False ' Untuk Memasukan Alamat ke Form utama
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try


        '850

        DGPerusahaan.GridColor = Color.White
        DGPerusahaan.DefaultCellStyle.ForeColor = Color.White
        DGPerusahaan.AlternatingRowsDefaultCellStyle.BackColor = Color.Purple
        DGPerusahaan.RowsDefaultCellStyle.BackColor = Color.DarkGreen
        Proses.CloseConn()


        DGPerusahaan.Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        'DGPerusahaan.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter

        Proses.OpenConn()

        Dim myadapter As New MySqlDataAdapter
        Dim sqlquery = "SELECT tawar01.kode_pelanggan AS 'KODE', " _
            & "pelanggan.nama AS 'NAMA PERUSAHAAN', tawar01.att AS 'PENERIMA', tawar01.kode AS 'PENAWARAN', tawar01.alamat as 'ALAMAT', tawar01.tgl AS 'TGL' " _
            & "FROM tawar01 INNER JOIN pelanggan " _
            & "ON tawar01.kode_pelanggan = pelanggan.kode " _
            & "WHERE pelanggan.nama LIKE '%" & Rep(txtCariPerusahaan.Text) & "%' ORDER BY tawar01.tgl DESC"

        Dim mycommand As New MySqlCommand
        mycommand.Connection = Proses.Cn
        mycommand.CommandText = sqlquery
        myadapter.SelectCommand = mycommand
        Dim totalbarang As Integer
        Dim mydata As MySqlDataReader
        mydata = mycommand.ExecuteReader()

        totalbarang = 0
        If (mydata.HasRows) Then
            While (mydata.Read)
                totalbarang = totalbarang + 1
            End While
        End If
        lbl_totalperusahaan.Text = Val(totalbarang)
        Proses.CloseConn()

    Catch ex As Exception
        MessageBox.Show("Error. Hubungi IT atau periksa ulang data yang di input" + ex.Message, "Hubungi IT", MessageBoxButtons.OK)
    End Try
End Sub

0 个答案:

没有答案