I have small issue, I have datagridview in form1 to which I insert data from form2 using SQL commands, but after button click which includes INSERT command the newly inserted value doesn't appear in form1's datagridview. Is there any way to solve this ?
So I had to make refresh button in form1 so I can refresh it every time something is inserted.
Thanks in advance.
This is the insert code in button click in form2: private void btn_zaj_uloz_Click(object sender, EventArgs e) {
SqlCommand prikaz = new SqlCommand
("INSERT INTO zajezd(akce,name,zeme,hotel,h_adresa,odjdate,pridate,pocdnu,pocnoc,klimax)values(@zakce,@zname,@zzeme,@zhotel,@zh_adresa,@zodjdate,@zpridate,@zpocdnu,@zpocnoc,@zklimax)", spojeni);
prikaz.Parameters.AddWithValue("zakce", zakce.Text);
prikaz.Parameters.AddWithValue("zname", zname.Text);
prikaz.Parameters.AddWithValue("zzeme", zzeme.Text);
prikaz.Parameters.AddWithValue("zhotel", zhotel.Text);
prikaz.Parameters.AddWithValue("zh_adresa", zh_adresa.Text);
prikaz.Parameters.AddWithValue("zodjdate", zodjdate.Text);
prikaz.Parameters.AddWithValue("zpridate", zpridate.Text);
prikaz.Parameters.AddWithValue("zpocdnu", zpocdnu.Text);
prikaz.Parameters.AddWithValue("zpocnoc", zpocnoc.Text);
prikaz.Parameters.AddWithValue("zklimax", zklimax.Text);
spojeni.Open();
prikaz.ExecuteNonQuery();
System.Data.DataTable dt = new System.Data.DataTable();
System.Data.SqlClient.SqlDataAdapter SDA = new System.Data.SqlClient.SqlDataAdapter("SELECT * FROM zajezd", spojeni);
SDA.Fill(dt);
spojeni.Close();
this.Close();
}