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