数据库链接是用dataset链接access的,table 只有帐户(name)和密码(password). 就是读不出来。。
private bool ValidateNow(string un, string pwd)
{
foreach (DataRow dr in tableDataSet.Tables["table"].Rows)
{
string oun = dr["name"].ToString();
string opwd = dr["password"].ToString();
if (oun == un && opwd == pwd)
return true;
}
return false;
}
private void button1_Click(object sender, EventArgs e) {
if (ValidateNow(textBox1.Text, textBox2.Text)) {
MessageBox.Show("成功");
} else {
MessageBox.Show("失败");
Application.Exit();
}
} }
private bool ValidateNow(string un, string pwd)
{
foreach (DataRow dr in tableDataSet.Tables["table"].Rows)
{
string oun = dr["name"].ToString();
string opwd = dr["password"].ToString();
if (oun == un && opwd == pwd)
return true;
}
return false;
}
private void button1_Click(object sender, EventArgs e) {
if (ValidateNow(textBox1.Text, textBox2.Text)) {
MessageBox.Show("成功");
} else {
MessageBox.Show("失败");
Application.Exit();
}
} }
http://community.csdn.net/Expert/TopicView1.asp?id=4696722