private void button1_Click(object sender, EventArgs e) { string strCon = "Provider=Microsoft.Jet.OL
privatevoidbutton1_Click(objectsender,EventArgse){stringstrCon="Provider=Microsoft.Je...
private void button1_Click(object sender, EventArgs e)
{
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\book.mdb";
OleDbConnection myCon = new OleDbConnection(strCon);
try
{
myCon.Open();
//测试连接
MessageBox.Show("Success Connection!" + myCon.State.ToString());
//使用DataSet
//string myComStr = "SELECT * FROM 表2 WHERE (登录名 = '" + this.textBox1.Text.ToString().Trim() + "' and 登录密码 = '" + this.textBox2.Text.ToString().Trim() + "')";
string myComStr = "SELECT * FROM 表2 WHERE (登陆名 = '" + this.textBox1.Text.ToString().Trim() + "' and 登陆密码 = '" + this.textBox2.Text.ToString().Trim() + "')";
//DataSet ds = new DataSet();
this.myad = new OleDbDataAdapter(myComStr, myCon);
this.ds.Clear();
this.myad.Fill(ds, "表2");
if (ds.Tables["表2"].Rows.Count == 1)
{
MessageBox.Show(textBox1.Text + "登陆成功", "恭喜");
if (this.comboBox1.Text == "学生")
{
学生信息窗口 frm = new 学生信息窗口();
frm.ShowDialog();
}
if (this.comboBox1.Text == "图书馆管理员")
{
图书管理窗口 f = new 图书管理窗口();
f.ShowDialog();
}
if (this.comboBox1.Text == "教师")
{
教师信息窗口 frm = new 教师信息窗口();
frm.ShowDialog();
}
}
else
{
MessageBox.Show("您不具备登陆权限!\n" + "可能有如下原因\n" + "1 用户名不存在\n" + "2 密码错误\n" + "请您尽快注册!", "ERROR");
}
}
catch (OleDbException oe)
{
MessageBox.Show(oe.Message);
}
finally
{
myCon.Close();
}
}
高手帮我看一下,是哪里出问题了,登录不了? 展开
{
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\book.mdb";
OleDbConnection myCon = new OleDbConnection(strCon);
try
{
myCon.Open();
//测试连接
MessageBox.Show("Success Connection!" + myCon.State.ToString());
//使用DataSet
//string myComStr = "SELECT * FROM 表2 WHERE (登录名 = '" + this.textBox1.Text.ToString().Trim() + "' and 登录密码 = '" + this.textBox2.Text.ToString().Trim() + "')";
string myComStr = "SELECT * FROM 表2 WHERE (登陆名 = '" + this.textBox1.Text.ToString().Trim() + "' and 登陆密码 = '" + this.textBox2.Text.ToString().Trim() + "')";
//DataSet ds = new DataSet();
this.myad = new OleDbDataAdapter(myComStr, myCon);
this.ds.Clear();
this.myad.Fill(ds, "表2");
if (ds.Tables["表2"].Rows.Count == 1)
{
MessageBox.Show(textBox1.Text + "登陆成功", "恭喜");
if (this.comboBox1.Text == "学生")
{
学生信息窗口 frm = new 学生信息窗口();
frm.ShowDialog();
}
if (this.comboBox1.Text == "图书馆管理员")
{
图书管理窗口 f = new 图书管理窗口();
f.ShowDialog();
}
if (this.comboBox1.Text == "教师")
{
教师信息窗口 frm = new 教师信息窗口();
frm.ShowDialog();
}
}
else
{
MessageBox.Show("您不具备登陆权限!\n" + "可能有如下原因\n" + "1 用户名不存在\n" + "2 密码错误\n" + "请您尽快注册!", "ERROR");
}
}
catch (OleDbException oe)
{
MessageBox.Show(oe.Message);
}
finally
{
myCon.Close();
}
}
高手帮我看一下,是哪里出问题了,登录不了? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询