
And finally the code:
| private void btnSnimi_Click(object sender, EventArgs e) { this.korisnikBindingSource.EndEdit(); //this.BindingContext[dsAB1, "stud"].EndCurrentEdit(); if (this.katvDataSet1.HasChanges()/*this.dsAB1.HasChanges()*/) { try { if (konekcija.State == ConnectionState.Closed) { konekcija.Open(); MessageBox.Show("otvorena konekcija"); } korisnikTableAdapter.Update(katvDataSet1.korisnik); //sqlDAStud.Update(dsAB1, "stud"); MessageBox.Show("Snimljene sve izmjene!"); } catch (System.Exception eSnimi) { MessageBox.Show("GRESKA: " + eSnimi.Message); } finally { konekcija.Close(); } } else { MessageBox.Show("Nema promjena za snimanje!"); } } |
adnanPosted Aug 9, 2010, 9:43 AM
Koteswararao MallisettiPosted Aug 9, 2010, 2:26 AM
dataset ds as new dataset
after filling that ds with data it will give to datagrid
datagrid1.datasource=ds
form this point onwards you don't bother about changes of the datagrid data why because that changes automatically updated on that datagrid datasource that is dataset ds but that changes will not updated on the backend tables to update on table also we call the update method of dataadapter but that adpter n=must be in commondbuilder then only update will work.