Winform DataGridView在最终更新后仍会显示数据

时间:2016-03-30 13:51:11

标签: c# winforms gridview datagridview

我正在使用C#.net开发一个winform应用程序,使用DataGridView来显示数据,但在上次更新后,DataGridView返回最后一行,但我想要{{1}返回一个空行或只显示标题...

nb:更新之前JmlKirimK值为1。

DataGridView

这是我的 try { con.Close(); con.Open(); MySqlCommand cmd = new MySqlCommand("Select PasienID, NoHP, JmlKirimK from datapasien where JmlKirimK ='1' AND StatusDiabetes='Ya'", con); DataTable dt = new DataTable(); MySqlDataAdapter da = new MySqlDataAdapter(cmd); da.Fill(dt); foreach (DataRow dr in dt.Rows) { con.Close(); con.Open(); nohp = Convert.ToString(dr[1]); idpasien = Convert.ToString(dr[0]); jml = Convert.ToString(dr[2]); Cursor.Current = Cursors.WaitCursor; if (objclsSMS.sendMsg(this.port2, nohp, this.txtisi.Text)) { MySqlCommand cmd3 = new MySqlCommand("UPDATE datapasien SET JmlKirimK='2' Where PasienID='" + idpasien.Trim() + "'", con); cmd3.ExecuteNonQuery(); terkirim = terkirim + 1; showgridkirimulang(); } else { tdkterkiri = tdkterkiri + 1; } showgridkirimreset(); } con.Close(); alert.ContentImage = SmsGatewayProlanis.Properties.Resources.Warning1; alert.CaptionText = "Status"; alert.ContentText = "Pesan Terkirim = " + terkirim + ", Pesan Tidak Terkirim = " + tdkterkiri; alert.Show(); } catch (Exception ex) { alert.ContentImage = SmsGatewayProlanis.Properties.Resources.Warning1; alert.CaptionText = "Status"; alert.ContentText = ex.Message; alert.Show(); ErrorLog(ex.Message); } 代码

DataGridView

0 个答案:

没有答案