Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh datagridview1 on form1 each time form2 is closed
    primarykey
    data
    text
    <p>How do I refresh <strong>datagridview1</strong> on form1 each time form2 is closed?</p> <p>i.e. <code>refreshDataGridView1()</code> needs to be run, but I'm not too sure how to go about initializing it.</p> <p>What needs to go in <code>refreshDataGridView1()</code>?</p> <pre><code>private void save_btn_Click(object sender, EventArgs e) { if (pgpText.Text.Trim().Length == 0) { MessageBox.Show("Please fill the following textbox: PGP"); } else if (teamText.Text.Trim().Length == 0) { MessageBox.Show("Please fill the following textbox: Team"); } else { using (OleDbConnection conn = new OleDbConnection()) { string pgp_new = pgpText.Text; string pgp_old = pgpOld.Text; string team = teamText.Text; conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='db.mdb'"; OleDbCommand command = new OleDbCommand(); command.Connection = conn; command.CommandText = "UPDATE PGP SET PGP=?,Team=? WHERE PGP=?"; command.Parameters.Add("pgp_new", OleDbType.VarChar).Value = pgp_new; command.Parameters.Add("team", OleDbType.VarChar).Value = team; command.Parameters.Add("pgp_old", OleDbType.VarChar).Value = pgp_old; conn.Open(); int affectedRows = (int)command.ExecuteNonQuery(); if (affectedRows == 0) { command.CommandText = "INSERT INTO PGP (PGP,Team) VALUES (?, ?)"; command.Parameters.RemoveAt(2); command.ExecuteNonQuery(); if (MessageBox.Show("Table Saved!", "Update", MessageBoxButtons.OK) == DialogResult.OK) { //refreshDataGridView1(); this.Close(); } } if (affectedRows &gt; 0) { if (MessageBox.Show("Table Saved!", "Update", MessageBoxButtons.OK) == DialogResult.OK) { //refreshDataGridView1(); this.Close(); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload