帮我看个数据库连接问题啊,连接ACCESS的。
string conStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\access\DBCommunity.mdb";//;Data Source=path; Jet OLEDB:Database Password=pwd;//OleDbConnection con = new OleDbConnection(conStr);
con.Open();
string cmdStr = "select * from 操作用户 where 用户名称='" + this.用户名称TextBox.Text + "' and 用户密码='" + this.用户密码TextBox.Text + "'";
OleDbCommand cmd = new OleDbCommand(cmdStr, con);
OleDbDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
MainForm newForm = new MainForm();
newForm.Show();
this.Hide();
}
else
{
Times++;
if (Times == 3)
{
MessageBox.Show("密码错误3次,请查证后再登录!");
this.Close();
}
else
{
MessageBox.Show("用户名或密码错误!");
}
}
reader.Close();
cmd.Connection.Close();
con.Close();
}
}
一直连接不上