Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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);
}
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900