private void button1_Click(object sender, EventArgs e)
        {
              string connstr = "Data Source=.;Initial Catalog=图书管理系统;Integrated Security=True";
              SqlConnection conn = new SqlConnection(connstr);
              conn.Open();
              string select = "select * form 管理员登陆表 where 账号='" + 账号.Text + "'and 密码 = '" + 密码.Text + "'";              this.Hide();
              Form4  a = new Form4();
              a.Show();

解决方案 »

  1.   

    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 + "'";              this.Hide();
                  Form4  a = new Form4();
                  a.Show();
                  }
                  catch(Exception ex)
                  {
                        throw ex;
                   }
      

  2.   

    private void button1_Click(object sender, EventArgs e) 
            { 
                  string connstr = "Data Source=.;Initial Catalog=图书管理系统;Integrated Security=True"; 
                  string select = "select * form 管理员登陆表 where 账号='" + 账号.Text + "'and 密码 = '" + 密码.Text + "'"; 
                  SqlConnection conn = new SqlConnection(connstr); 
                  SqlCommand cmd=new SqlCommand(select ,con);
                    try
                   {
                  conn.Open(); 
                  cmd.ExecuteNonQuery();
                  conn.Close();
                  this.Hide(); 
                  Form4  a = new Form4(); 
                  a.Show();
                  }
                  catch(Exception ex)
                   {
                     throw ex;
                    conn.Close();
                    }
      

  3.   


            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 Count(*) form 管理员登陆表 where 账号='" + 账号.Text + "'and 密码 = '" + 密码.Text + "'";               SqlCommand cmd = new SqlCommand(select,conn);
                  if(cmd.ExecuteScalar()==1)
                  {
                      this.Hide(); 
                      Form4  a = new Form4(); 
                      a.Show();
                  }
                  else
                  {
                      MessageBox.Show("用户名或密码输入错误");
                  }   
                  }
                  catch(Exception ex)
                  {
                      MessageBox.Show(ex.ToString());
                  }           
            }
      

  4.   

    错误 1 类、结构或接口成员声明中的标记“catch”无效 大哥这是怎么回事??
      

  5.   

    try
    {
      ..... //statement1. 你的程序过程.
    }
    catch (Exception ex) //在try{}范围里出现异常的话直接跳到这里.<捕捉异常过程>
    {
      MessageBox.Show(ex.ToString());
    }