Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-09-2009
Member
 
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".
Reply With Quote
  #2  
Old 25-09-2009
Member
 
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];
Reply With Quote
  #3  
Old 25-09-2009
Member
 
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"
Reply With Quote
  #4  
Old 25-09-2009
Member
 
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".
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 07:54 PM.