Results 1 to 4 of 4

Thread: How to update Database with Changes made to the DataGridView

  1. #1
    Join Date
    Apr 2008
    Posts
    242

    How to update Database with Changes made to the DataGridView

    I want to update table at backend in database through making changes in datagridview. Any changes made to the records in the GridView Changes should be Reflected into the Database. What I want to do is update the database using the data adapters InsertCommand after a user adds a new row to the grid. After making changes in "Datagridview" when user clicked "Save" button, whichever changes made in datagridview should get reflect at backend in respected table like "EmpDetails".

  2. #2
    Join Date
    Oct 2008
    Posts
    180

    Re: How to update Database with Changes made to the DataGridView

    You should use a Command Builder to update records so that changes made to the dataset can be reflected into the database. Use this code to populate datagridview

    SqlDataAdapter check=new SqlDataAdapter("select * from product",strcon);
    SqlCommandBuilder result=new SqlCommandBuilder(check);
    DataSet result = new DataSet();
    check.Fill(result);
    dataGridView1.DataSource=check.Tables[0];

  3. #3
    Join Date
    Feb 2006
    Posts
    172

    Re: How to update Database with Changes made to the DataGridView

    You will use the SqlDataAdapter.Update method to update your database when a user clicks on your Save button. This is an example that I am using without any problem. I think that's the easy way (at least for me!), "Dynamic SQL generation for the UpdateCommand is not supported against a SelecCommand that does not return any key column information"

  4. #4
    Join Date
    Jan 2009
    Posts
    96

    Re: How to update Database with Changes made to the DataGridView

    I am having "Datagridview", "Edit" and "Save" button on WinForm and table "EmpDetails" at backend in databse. 2005 will for the most part create most of the code for you and when it does the coding is easier to do. If you create a datagridview as the initial form database object it create a navigation bar etc for you. this will bring in all the code you need for normal operations. I am filling "Datagridview" with table "EmpDetails". When user clicked "Edit" button he should allowed to make changes in "Datagridview".

Similar Threads

  1. DataBase update failure
    By Santiaago in forum Networking & Security
    Replies: 5
    Last Post: 10-04-2010, 03:16 PM
  2. Update database with Hibernate
    By CheckMeNot in forum Software Development
    Replies: 3
    Last Post: 10-12-2009, 02:42 PM
  3. Insert DataGridview into database
    By Neil'o in forum Software Development
    Replies: 3
    Last Post: 24-09-2009, 11:28 AM
  4. Changes made in the Database does not reflect on the front page
    By Rixwel in forum Software Development
    Replies: 3
    Last Post: 15-09-2009, 07:21 PM
  5. How to update two database tables coldfusion
    By Rixwel in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 03:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,630,229.32386 seconds with 17 queries