Click here to Skip to main content
Sign Up to vote bad
good
Hi,
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...
 

Thanks
Posted 14 Jan '13 - 12:00
jstu266310


1 solution

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 
    myDataAdapter.Update(xDataTable);
}
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 565
1 Maciej Los 260
2 Slacker007 240
3 OriginalGriff 235
4 Aarti Meswania 175
0 Sergey Alexandrovich Kryukov 9,118
1 OriginalGriff 7,134
2 CPallini 3,803
3 Rohan Leuva 3,135
4 Maciej Los 2,558


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid