Vote count:
0
I'm developing the username/password creation system for my program. It's just going to be used in a computing lab, and I'm just going to have a central Access database that distributes through scripts on the lab machines. Or that's the plan right now. I can't remember the proper code to insert the info into the database to save my life though. This is what I've got so far. The hashing and salting seem to be going fine, I just can't shove it into the database. The name of the table is regulate.
I'm getting "number of query fields and destination fields are not the same".
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=access.mdb";
conn.Open();
string Name = txtName.Text;
string PW = txtHash.Text;
string Salt = txtSalt.Text;
OleDbCommand cmmd = new OleDbCommand("INSERT INTO regulate(regulate) Values(@NAME, @PASSWORD, @SALT)", conn);
if (conn.State == ConnectionState.Open)
{
cmmd.Parameters.Add("@NAME", OleDbType.VarWChar, 100).Value = Name;
cmmd.Parameters.Add("@PASSWORD", OleDbType.VarWChar, 500).Value = PW;
cmmd.Parameters.Add("@SALT", OleDbType.VarWChar, 10).Value = Salt;
try
{
cmmd.ExecuteNonQuery();
MessageBox.Show("DATA ADDED");
conn.Close();
}
catch (OleDbException expe)
{
MessageBox.Show(expe.Message);
conn.Close();
asked 24 secs ago
How do I enter information into an Access Database through C#?
Aucun commentaire:
Enregistrer un commentaire