您好我有问题:我的OleDbCommand无法正常工作。
代码元素:
2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]
答案 0 :(得分:1)
password
的字段和一个纯文本值,你绝不应该将密码存储为纯文本。而是存储密码的单向散列。你可以使用很多图书馆。private void Btn_Click(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = connection;
cmd.CommandText = "INSERT INTO [Account] ([Nick],[Password]) values (?,?);";
// note that order is critical here
command.Parameters.Add(new OleDbParameter("@nick", OleDbType.VarChar)).Value = NickEnter.Text;
command.Parameters.Add(new OleDbParameter("@password", OleDbType.VarChar)).Value = PassEnter.Text;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Error! | " + ex, "Error!");
}
}