Hello guys,
I have this code which does:
Automatically updates changes in datagridview
I need it to:
As I don't have column named "akce" in datagridview I need it to automatically insert to every new row value from zakce.Text to column "akce" in sql table.
Is there any way to do that? I tried the code which is now commented but it creates new row instead adding this to new row in datagridview.
da = new SqlDataAdapter("select * from zajsluz WHERE akce="+zakce.Text, spojeni); //SqlCommand a = new SqlCommand("INSERT INTO zajsluz(akce)values(@akce)"); //a.Parameters.AddWithValue("@akce", zakce.Text); sqlCommandBuilder = new SqlCommandBuilder(da); dt = new DataTable(); da.Fill(dt); dtg_sluzby.DataSource = dt; public void btn_uloz_sl_Click(object sender, EventArgs e) { try { da.Update(dt); MessageBox.Show("Služby byly editovány!"); } catch (Exception se) { MessageBox.Show(se.Message); }
Thanks in advance.