Search code examples
c#sql-serverdatatabledataviewdatarowview

Deleting DataRowView from a DataView C# and not committing changes to DB


I am iterating through a DataView. If I don't want a row based on a predefined condition, I am deleting it. After I iterate through the entire DataView, I want to bind this updated DataView back to a control but not commit the changes to the SQL Server Database table. Will this automatically trigger the deletes in the actual sql server table? If so, how can I stop that from happening.

 foreach (DataRowView dR in dvUpdatedRankings)
 {
     // If some logic is true, delete row
     if(DeleteFlag == True)
     {
         dR.Delete();
     }

 }

Solution

  • The dataview is no way related to sql server db..It serves just as holder to save the value fetched from db,, any modification done to it will only reside in servers memory till the scope of the object is lost. Hence db would not be changed.

    It is like a one way communication.. you got the data from db to DataView. and the connection is closed and now db and Dataview are two seperate things!