我正在做一个登录和注册表格,当我尝试注册它把用户名和密码在SQL数据库中,但它这样做:
我的项目看起来是这样的:Parameters.Add在SQL项目C#
static public void Insert(string _userName)
{
try
{
connection.Open();
SqlCeCommand commandInsert = new SqlCeCommand("INSERT INTO [Table](username) VALUES(@userName)", connection);
commandInsert.Parameters.Add("@userName", _userName);
commandInsert.ExecuteNonQuery();
}
catch (SqlCeException expection)
{
MessageBox.Show(expection.ToString());
}
finally
{
connection.Close();
}
}
static public void Insertt(string _password)
{
try
{
connection.Open();
SqlCeCommand commandInsert = new SqlCeCommand("INSERT INTO [Table](password) VALUES(@Password)", connection); ;
commandInsert.Parameters.Add("@password", _password);
commandInsert.ExecuteNonQuery();
}
catch (SqlCeException expection)
{
MessageBox.Show(expection.ToString());
}
finally
{
connection.Close();
}
}
和按钮注册看起来像这样:
private void button1_Click(object sender, EventArgs e)
{
if (insertBox.Text != "" || deleteBox.Text != "")
{
SQLFunctions.Insert(insertBox.Text);
SQLFunctions.Insertt(deleteBox.Text);
SQLFunctions.Refresh(this.dataGridView1);
}
else
{
MessageBox.Show("login failed");
}
}
感谢您的帮助
请说明问题,不只是把我们的程序,并且希望我们的调试/修复它为您 – Steve 2014-10-09 17:20:46
你为什么将在单独的记录的用户名和密码?为什么有两个功能呢?是什么让'Insertt'与'Insert'不同?另外,请不要以纯文本存储用户密码。如果用户使用他们的密码信任您,请妥善散列这些密码,以免他们被读取。 – David 2014-10-09 17:24:13