日期:2014-05-18  浏览次数:20932 次

还是这段代码~~!!
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'附近有语法错误。







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

------解决方案--------------------
select * form 管理员登陆表 where 账号='" + 账号.Text + "'and 密码 = '" + 密码.Text + "'";


是 from 不是 form