When I try to save a new (inserted) record via the following code:
DataRow row = dataTable.Rows [currRec];
// update data in DataSet from data entry WinForm
row.BeginEdit ();
row ["Title"] = txtTitle.Text;
row ["FirstName"] = txtFirstName.Text;
row ["MiddleName"] = txtMiddleName.Text;
row ["LastName"] = txtLastName.Text;
row ["Suffix"] = txtSuffix.Text;
row ["Phone"] = txtPhone.Text;
row ["EmailAddress"] = txtEmailAddress.Text;
row.EndEdit ();
try
{
dataAdapter.Update (dataSet, "Person.Contact");
}
catch (System.Runtime.InteropServices.ExternalException exc)
{
MessageBox.Show (exc.Message);
}
I get the following exception message:
Cannot insert the value NULL into column 'PasswordHash', table 'AdventureWorks.Person.Contact'; column does not allow nulls. INSERT fails. The statement has been terminated.
How do I get an appropriate PasswordHash value that I can put it in the newly-created record I'm inserting into the database?
For what it’s worth, the environment I’m working in is:
32-bit
SQL Server 2008 Express with Advanced Services
database:SQL2008 AdventureWorks (schema.table: Person.Contact)
SQL Server 2008 Management Studio Express
Visual C# 2008 Express
LisaPosted Mar 30, 2009, 2:39 AM
where does the value of that column come from 'PasswordHash' are you getting the password from the user and do you have to hash it and save ??
If Yes then
System.Security.Cryptography.MD5CryptoServiceProvider exists in Dotnet where you can add and use the computehash function which returns a hashed password for a given string.
Hope it Helps,
Thanks,
Lisa