以下是登陆procedure:
    private void button1_Click(object sender, System.EventArgs e)
{

SqlConnection sqlConnection1=new SqlConnection("Persist
Security Info=False;User ID=NIRVANA;Initial Catalog=yifufang;Data Source=(local)");
SqlCommand sqlCommand1=new SqlCommand();
sqlCommand1.Connection=sqlConnection1;
    sqlConnection1.Open();
    sqlCommand1.CommandText="select count(*) from operator where 管理员姓名 = '" + textBox1.Text + "' and 管理员密码 = '" + textBox2.Text + "'";
string returnValue=sqlCommand1.ExecuteScalar().ToString();

if (returnValue=="0")
MessageBox.Show("您输入的用户名或者密码错误,请重新输入!","登录",MessageBoxButtons.OK,MessageBoxIcon.Warning);
else
{
Form1 MainForm=new Form1();//进入主界面
MainForm.Show();


}

sqlConnection1.Close();       
}运行以后可以编译成功,但是输入用户名和密码以后,发生异常,提示系统错误!
各位达人,帮忙啊

解决方案 »

  1.   

    SqlConnection sqlConnection1=new SqlConnection("User ID=NIRVANA;Database=yifufang;Password =;Data Source=(local)");
      

  2.   

    SqlConnection sqlConnection1=new SqlConnection("User ID=NIRVANA;Database=yifufang;Password =;Data Source=(local);");
      

  3.   

    可能是数据库没连接上,检查SqlConnection sqlConnection1=new SqlConnection("Persist
    Security Info=False;User ID=NIRVANA;Initial Catalog=yifufang;Data Source=(local)");
    是否少了password等
      

  4.   

    要是这样连呢
    SqlConnection sqlConnection1=new SqlConnection("Server=localhost;UID=NIRVANA;pwd=pwd;database=yifufang;");
      

  5.   

    上面的方法我都试过了。不行啊。。
    编译依然可以通过,输入用户名密码以后提示系统错误,程序停在
    sqlCommand1.CommandText="select count(*) from operator where 管理员姓名 = '" + textBox1.Text + "' and 管理员密码 = '" + textBox2.Text + "'";
    这一句,就不执行了!急。
      

  6.   

    具体错误如下::
      未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。其他信息: 系统错误。
      

  7.   

    SqlConnection sqlConnection1=new SqlConnection("Server=(local);UID=sa;pwd=密码;database=数据库;");前提,数据库支持windows和SQL server混合验证,查询分析器可以联接上..查询语句上,查错用Response.Write()输出来看一下