综艺大热门2015下载:C#中找错

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/04 19:18:09
private void button1_Click(object sender, System.EventArgs e)
{

string sconn="provider=SQLOLEDB;server=(local);database=student_info;uid=sa;pwd=;";
SqlConnection s=new SqlConnection(sconn);
string scomm="select sadmin,spassword from student_adminlogin where sadmin='"+textBox1.Text+"' and spassword='"+textBox2.Text+"'";
SqlCommand t=new SqlCommand(scomm,s);
SqlDataReader p=t.ExecuteReader();
string x;

if(p.Read())
{
x=p[0].ToString();
if(x==null)
MessageBox.Show("something is wrong !");
else
{
Form3 f3=new Form3();
f3.Show();
}

}
else
MessageBox.Show("cuo wu");
}

你在使用t.ExecuteReader(); 的时候指定的连接没有打开
少了s.open()

你至少应该先说一下这段程序怎么了。