CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    23

    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.

  2. #2
    Join Date
    Dec 2007
    Posts
    234

    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
    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

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
  •  





Click Here to Expand Forum to Full Width

Featured