Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding modified column in a DataRow
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
00978781
Message ID:
00979720
Vues:
10
Hey Cathi!

I figured there was some way to get at this using the DataRowVersion, but I missed this overload of the DataRow when I was experimenting. Thanks for pointing it out!!

~~Bonnie


>Hi Andrew,
>
>If you want to look to see if a Data column has been modified, you can use the DataRowVersion enum to get that information. Here is some same code:
>
>
>' Compare the proposed version with the current.
>If myDataRow.HasVersion(DataRowVersion.Proposed) Then
>   If r("myColumn", DataRowVersion.Current) Is r(1, DataRowVersion.Proposed) Then
>      MessageBox.Show("The original and the proposed are the same")
>   End If
>Else
>   MessageBox.Show("No new values proposed")
>End If
>
>
>>Hi,
>>
>>How do you know which column of a DataRow has modified data? I can find the rows that have been modified but can't figure out which field has been changed.
>>
>>The problem is that I need to encrypt user's passwords before they are stored in the database. I only want to encrypt the password if the user is an added row (new user so the password has not been encrypted yet) or if an existing user's password has been modified and then only if the password has been changed (I don't need to run the encryption if some other data other that the password has been changed otherwise the encryption will run on an already encrypted password). I am overriding a pre-save hook method in a framework that only gives a reference to a DataTable.
>>
>>I tried using the DataSet.Merge() but I can't add the datatable to a new DataSet as it already belongs to another DataSet that I don't have a reference to.
>>
>>Example :
>>
>>
>>// dt is a DataTable given as a parameter to the hook method I am overriding
>>
>>foreach (DataRow dataRow in dt.Rows)
>>{
>>  if (dataRow.RowState == DataRowState.Added)
>>  {
>>    dataRow["Password"] = Encrypt(dataRow["Password"].ToString());
>>  }
>>  else if (dataRow.RowState == DataRowState.Modified)
>>  {
>>    // todo : only encrypt password if it has been changed
>>  }
>>}
>>
>>
>>Thanks in advance,
>>
>>Andrew Fuller
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform