I have 2 forms that are form A and form B ,
form A allows the user to insert and update student information.
form B is just a DataGridView and the button there.
When I insert a student in form A , I go to form B , the new student does not appear in the DataGridView, and if I re-run the program, the new student will appear in form B
I tried using this button on form b
datagridview1.refresh(); datagridview1.update();
but it still does not work.
Edited by:
My code to insert a worker
cmd = new OleDbCommand("insert into FWINFOS (ID,Name,Gender,DateOfBirth,Race,WorkingPlace,PassportNO,DateOfExpire,[Position],Photo) values('" + textBox5.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + dateTimePicker1.Value + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + dateTimePicker2.Value + "',@Position,@Photo)", con); cmd.Parameters.AddWithValue("@Position", comboBox1.SelectedText.ToString()); conv_photo(); con.Open(); int n = cmd.ExecuteNonQuery(); //cmd.ExecuteNonQuery(); con.Close(); if (n > 0) { MessageBox.Show("Inserted"); loaddata(); rno++; } else MessageBox.Show("No Insert"); }
my Datagridview1(Form2) does not update automatically when I inserted a new worker. But if I re-run the application, a new worker will appear.