private void button1_Click(object sender, EventArgs e)
        {
             string connstr = "Data Source=.;Initial Catalog=图书管理系统;Integrated Security=True"; 
              SqlConnection conn = new SqlConnection(connstr); 
              try 
              { 
              conn.Open(); 
              string select = "select * form 管理员登陆表 where 账号='" + 账号.Text + "'and 密码 = '" + 密码.Text + "'";
              SqlCommand cmd = new SqlCommand(select, conn);
              if (cmd.ExecuteScalar() != null)               {
                  this.Hide();
                  Form4 a = new Form4();
                  a.Show();
              }
              else
              {
                  MessageBox.Show("用户名或密码输入错误");
              }                 } 
              catch(Exception ex) 
              {
                  MessageBox.Show(ex.ToString());
可以运行   运行后 我一点登陆  就出现System.Data.SqlClient.SqlException:'form'附近有语法错误。

解决方案 »

  1.   

     string select = "select * from 管理员登陆表 where 账号='" + 账号.Text + "'and 密码 = '" + 密码.Text + "'"; 
      

  2.   

    "'and 密码 = '" + 密码.Text + "'"; 
    and 前面加空格
      

  3.   

    select * form 管理员登陆表 where 账号='" + 账号.Text + "'and 密码 = '" + 密码.Text + "'";
    是  from 不是 form
      

  4.   

    string select = "select * from 管理员登陆表 where 账号='" + 账号.Text + "' and 密码 = '" + 密码.Text + "'"; 
    加上一楼的空格
      

  5.   

    "select * form 管理员登陆表
    是from 不是form