Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding modified column in a DataRow
Message
From
20/01/2005 02:52:11
 
 
To
All
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Finding modified column in a DataRow
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
00978781
Message ID:
00978781
Views:
73
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
Next
Reply
Map
View

Click here to load this message in the networking platform