C#做学生成绩管理系统,可是出现函数fill()异常。向高手求救。 15
privatevoidbutton1_Click(objectsender,EventArgse)//学生登录按钮{if(textBox1.Text==""||textB...
private void button1_Click(object sender, EventArgs e)//学生登录按钮
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("输入登录信息不完整,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
string Constr = @"server=(local);user id=081842216;pwd=123456;database=20101207-2134";
SqlConnection con = new SqlConnection(Constr);
string SqlStr = "select * from slogin where sno = '" + textBox1.Text + "' and spwd = '" + textBox2.Text + "'";
SqlDataAdapter ada = new SqlDataAdapter(SqlStr,con);
DataTable dt = new DataTable();
ada.Fill(dt);
//int i = dt.Rows.Count;
// if (i >= 1)
//{
Form2 myf = new Form2();
myf.Show();
// Form5 ff = new Form5();
// ff.Show();
// }
// else
{
// MessageBox.Show("用户名或密码不正确,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
} 展开
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("输入登录信息不完整,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
string Constr = @"server=(local);user id=081842216;pwd=123456;database=20101207-2134";
SqlConnection con = new SqlConnection(Constr);
string SqlStr = "select * from slogin where sno = '" + textBox1.Text + "' and spwd = '" + textBox2.Text + "'";
SqlDataAdapter ada = new SqlDataAdapter(SqlStr,con);
DataTable dt = new DataTable();
ada.Fill(dt);
//int i = dt.Rows.Count;
// if (i >= 1)
//{
Form2 myf = new Form2();
myf.Show();
// Form5 ff = new Form5();
// ff.Show();
// }
// else
{
// MessageBox.Show("用户名或密码不正确,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询