Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataRow.BeginEdit, EndEdit, and AcceptChanges methods
Message
De
01/02/2005 13:59:12
 
 
À
01/02/2005 13:51:46
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 1.1
Database:
MS SQL Server
Divers
Thread ID:
00982570
Message ID:
00982804
Vues:
28
I assume that you go through the textfile and find the matching row in your datatable? Would it be possible to do this in reverse (go through your datatable and see if there's matching in the text file)? This way, you can flag the unchecked rows rather than flag the checked rows (and it won't matter that they are marked as modified, since you have to update the unchecked rows anyway with an inactive status). That way, your checked rows will only be modified if you have to make changes to them.

~~Bonnie



>The rows fall into four categories: in the textfile, not in the database (addition), in the textfile same as database (verification), in the textfile different from the database (update), and not in the textfile, in the database (deactivation).
>
>I change a flag in unchecked records to indicate it is no longer inactive.
>
>The 95% my records are verified, 4% are updated, 1% are added, and the number of deactivations is very rare (less than 1%) but I need to catch them. I would rather only update the 5% of my data table that requires it, not the entire 100%.
>
>Thanks for thinking about this.
>
>>David,
>>
>>And what are you doing with the rows that have not been checked?
>>
>>~~Bonnie
>>
>>
>>
>>>I want to retrieve data from a database, compare it data in a text file, update the data table to match the text file, and keep track of which records in the database were not checked because they weren't listed in the text file.
>>>
>>>I added a column to my datatable called "IsChecked" that holds a boolean value initialized to false. As I examine each row, I set IsChecked = true. Unchecked rows are VERY rare.
>>>
>>>Only a small number of rows actually differ from the data in my text file and I only want to send update statements to the database for rows which really require updates.
>>>
>>>My problem is that setting IsChecked = true sets the RowState value for the row to Modified even if though the other columns don't get changed, so that when I save, an update statement for every row is sent back to the DB.
>>>
>>>I couldn't find a way to use BeginEdit, EndEdit, and AcceptChanges to make it work. Deleting the IsChecked column didn't help, either.
>>>
>>>Am I just misusing my DataTable by using it to store information that doesn't exist in my database? Should I track which rows have been read in a separate data structure?
>>>
>>>If anyone can recommend an online resource that will help me understand how to use this IsChecked column without DataRows thinking that they have really been changed, I would appreciate it.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform