Click here to Skip to main content
13,301,619 members (65,982 online)
Rate this:
Please Sign up or sign in to vote.
Rightnow the solution we are using in which there is datatable displayed via dataset on webpage..When page loads this table will be by default at that page...and there is one button called as save button..this data table user can edit...and when the user press the save button with out making any changes in datatable it will run a stored procedure and update the result to database table still if users havent made any of changes...

Now here is the problem part :::
now the user requirements is like this they want to update in database only those rows , whose contents has been changed ..NOT OF EACH AND EVERY ROW....

according to me if i compare the content of data table on webpage with sql servers database table..and if contents are different only then i can run stored procedure which in turn update the database...But how can I do this..I need help very urgently...

Posted 14-Jan-13 13:00pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

DataTable has a method called GetChanges which returns all changes made to the table after the last AcceptChanges is called.

see here[^] for more
[Code sample]
private void UpdateDataTable(DataTable table, 
    OleDbDataAdapter myDataAdapter)
    DataTable xDataTable = table.GetChanges();
    // Check the DataTable for errors. 
    if (xDataTable.HasErrors)
        // Insert code to resolve errors.
    // After fixing errors, update the database with the DataAdapter 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100