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:
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
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi