0
我在我的VS 2013中创建了一个数据库,并将其添加为数据源。 VS已经产生了我的数据库中的类和方法insert
:无法填充数据库C#
private void registrationButton_Click(object sender, EventArgs e)
{
var adapter = new LogPassDataSetTableAdapters.TableTableAdapter();
var table = new LogPassDataSet.TableDataTable();
var data = adapter.GetData();
MD5 md5 = new MD5CryptoServiceProvider();
Form1 form1 = new Form1();
var pass = passwordTextR.Text.ToString();
byte[] result = md5.ComputeHash(Encoding.UTF8.GetBytes(pass));
for (int i = 0; i <= data.Rows.Count; i++)
{
if (data.Rows.Count == 0)
{
adapter.Insert(logInTextR.Text.ToString(), BitConverter.ToString(result).Replace("-", string.Empty));
MessageBox.Show("Registration complete");
break;
}
else if (logInTextR.Text.ToString() == data[i].Login.ToString())
{
MessageBox.Show("This login already use");
break;
}
else if (i == data.Rows.Count)
{
adapter.Insert(logInTextR.Text.ToString(), BitConverter.ToString(result).Replace("-", string.Empty));
MessageBox.Show("Registration complete");
break;
}
}
this.Hide();
form1.Show();
}
这个代码不填充数据库。问题是什么?你能帮我吗?
MD5哈希来存储密码= BAD IDEA。看到这个关于[安全哈希和盐的密码](http://stackoverflow.com/a/401684/945456)(这个问题是关于PHP的,但适用相同的原则)。 Jeff Atwood的这篇文章也称为“你可能会错误地存储密码”(http://blog.codinghorror.com/youre-probably-storing-passwords-incorrectly/)。 – 2014-09-12 14:51:09