There is a class Func.cs , in it a function:
public static void LoadTable(string table) { using (MySqlConnection con = new MySqlConnection("----------------------------")) { try { con.Open(); string sql = String.Format("SELECT * FROM `{0}`", table); using (MySqlCommand cmd = new MySqlCommand(sql, con)) { using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd)) { using (DataTable dt = new DataTable()) { sda.Fill(dt); Form2 f = new Form2(); f.dataGridView1.DataSource = dt; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } } LoadTable call this:
private void button1_Click(object sender, EventArgs e) { Func.LoadTable("proverka"); } As a result, the data in the dataGridView does not add.
If to take out this function from a class, then it works.

this.dataGridView1.DataSource = dt;. If you have a class in which you want to do something, then during its initialization, transfer the form there and do what you need ... you just don’t provide enough code, we are just wondering how it is now. - Denis Bubnov