本文介绍了操作无效,因为它导致对SetCurrentCellAddressCore函数的可重入调用。 VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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 When I call this form from another form
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
推荐答案
>>操作无效,因为它会导致对SetCurrentCellAddressCore函数的重入调用。
>>Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.
DataGridView引发异常,以防止发生无限循环。原因通常是以下之一:
The exception is raised by the DataGridView in order to prevent an infinite loop from occurring. The cause of this is usually one of the following:
这篇关于操作无效,因为它导致对SetCurrentCellAddressCore函数的可重入调用。 VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!