Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding modified column in a DataRow
Message
De
20/01/2005 02:52:11
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Finding modified column in a DataRow
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
00978781
Message ID:
00978781
Vues:
71
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform