J
JX
Trying to learn some asp dotnet and can't get an insert into MSAccess to
work. Can anyone point out my mistakes here:
Access Table is: Users with 3 columns - UserName Text(255), PasswordHash
Text(40) and salt text(10)
private bool InsertRecord(string asUserName, string asHashedPassword, string
asKey)
{
OleDbConnection conn = new OleDbConnection( DataSource );
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd;
try
{
conn.Open();
cmd = new OleDbCommand("INSERT INTO Users (UserName, PasswordHash, salt) " +
"VALUES (@In1, @In2, @In3)", conn);
cmd.Parameters.Add("@UserName", OleDbType.VarChar, 525 , asUserName);
cmd.Parameters.Add("@PasswordHash", OleDbType.VarChar, 40,
asHashedPassword);
cmd.Parameters.Add("@salt", OleDbType.VarChar, 10, asKey);
lblMessage.Text = "Inserting";
da.InsertCommand = cmd;
lblMessage.Text = "Done Inserting: " + In1;
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
}
finally
{
conn.Close();
}
return true;
}
work. Can anyone point out my mistakes here:
Access Table is: Users with 3 columns - UserName Text(255), PasswordHash
Text(40) and salt text(10)
private bool InsertRecord(string asUserName, string asHashedPassword, string
asKey)
{
OleDbConnection conn = new OleDbConnection( DataSource );
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd;
try
{
conn.Open();
cmd = new OleDbCommand("INSERT INTO Users (UserName, PasswordHash, salt) " +
"VALUES (@In1, @In2, @In3)", conn);
cmd.Parameters.Add("@UserName", OleDbType.VarChar, 525 , asUserName);
cmd.Parameters.Add("@PasswordHash", OleDbType.VarChar, 40,
asHashedPassword);
cmd.Parameters.Add("@salt", OleDbType.VarChar, 10, asKey);
lblMessage.Text = "Inserting";
da.InsertCommand = cmd;
lblMessage.Text = "Done Inserting: " + In1;
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
}
finally
{
conn.Close();
}
return true;
}