C#登录验证的问题
private void button1_Click(object sender, EventArgs e){
if (comboBox1.Text == "")
MessageBox.Show("用户名不能为空");
else
if (textBox1.Text == "")
MessageBox.Show("请输入密码");
string name = comboBox1.Text.Trim();
string password = textBox1.Text.Trim();
string path = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
path += @"\1.mdb";
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + path;
OleDbConnection conn = new OleDbConnection(constr);
conn.Open();
OleDbCommand cmd = new OleDbCommand();
= "select * FROM DB_user where user_id='" + name + "' and password='" + password + "'";
Int32 count = Convert.ToInt32(cmd.ExecuteScalar()); //提示说未初始化……
if (count>0)
{
MessageBox.Show("OK");
}
else
{
MessageBox.Show("NO");
}
}
Int32 count = Convert.ToInt32(cmd.ExecuteScalar()); //提示说未初始化……
请各位给看看,教教小弟,看看是哪里的问题