建立学生管理系统中运行这种错误怎么解决?
[align=center][/align]
这下面是代码:
}
if (radioButton1.Checked == true)
{
string OleDb= string.Format("select count(*) from Users where User_id='{0}' and User_password='{1}'and User_power='{2}'", this.textBox1.Text, this.textBox2.Text, 1);
OleDbCommand comm = new OleDbCommand(OleDb, conn); // 创建comm对象
int count = (int)comm.ExecuteScalar();//执行查询,并返回查询
if (count == 1)//判断是否存在这样一列
{
this.Hide();
Form2 f2 = new Form2();
f2.Show();
}
else
{
MessageBox.Show("不存在此用户");
}
}
if (radioButton2.Checked == true)
{
string OleDb= string.Format("select count(*) from Users where User_id='{0}' and User_password='{1}'and User_power='{2}'", this.textBox1.Text, this.textBox2.Text, 0);
OleDbCommand comm = new OleDbCommand(OleDb, conn); // 创建command对象
int count = (int)comm.ExecuteScalar();//执行查询,并返回查询
if (count == 1)//判断是否存在这样一列
{
this.Hide();
Form8 f8 = new Form8();
f8.passbb(textBox1.Text);
f8.Show();
}
else
{
MessageBox.Show("输入有误,请从新输入!");
}
}
}
catch(Exception )
{
throw new Exception("产生异常!");
}
}
private void button2_Click(object sender, EventArgs e)
{
radioButton1.Checked = true;
textBox1.Text = "";
textBox2.Text = "";
textBox1.Focus();
}
private void radioButton2_Click(object sender, EventArgs e)
{
textBox1.Focus();
}
private void Form1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Focus();
}
}
}
[解决办法]
断点跟进。。
[解决办法]
catch(Exception )
{
throw new Exception("产生异常!");
}
=>
catch(Exception exp)
{
MessageBox.Show(exp.Message);
}
看看显示什么。
[解决办法]