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 :
foreach (DataRow dataRow in dt.Rows)
{
if (dataRow.RowState == DataRowState.Added)
{
dataRow["Password"] = Encrypt(dataRow["Password"].ToString());
}
else if (dataRow.RowState == DataRowState.Modified)
{
}
}
Thanks in advance,
Andrew Fuller