|
-
May 10th, 2010, 04:09 AM
#1
update changes from gridview to database?
0
answers
0 votes 1
view
Tags: SQL
Plz help me out to resolve a conflict. I have made untiring efforts to resolve but coudln't. I have showed my data in gridivew now in windows forms now i want that when i make chages on the gridview using it like an excel sheet. These changes should also be reflected back in database. I have used this code.
da = new SqlDataAdapter();
cb = new SqlCommandBuilder(da);
myGridView.DataSource = ds.Tables["UserDetails"];
ds.AcceptChanges();
da.Update(ds, "UserDetails");
con.Close();what's wrong?
how can i edit specific cell values.
-
May 11th, 2010, 12:23 PM
#2
Re: update changes from gridview to database?
Don't use AcceptChanges.... What AcceptChanges does is say "OK, I don't care what data has changed. I don't care if it's been saved or not, mark ALL ROWS as UNCHANGED." So at that point, there are no changes to your dataset. When you then call .Update on it, because all of the data is "unchanged" no data is written to the database.
-tg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|