SqlConnection cn = new SqlConnection(); 
            cn.ConnectionString = "Data Source=192.168.16.71;Initial Catalog=myWork;User ID=sa;Password=sa";
           
            try
            {
                cn.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = cn;
               
                string sql2 = "select * from dbo.工作微博 where 姓名='" + this.textBox1.Text + "' and 密码='" + this.textBox2.Text + "'";
                cmd.CommandText = sql2; 
                cmd.CommandType = CommandType.Text;
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read()) //如果找到用户信息,说明登录成功
                {                   
                    switch ("select 权限 from dbo.工作微博 where 姓名='" + this.textBox1.Text + "'")
                    { 
                        case"0":
                            Form2 newForm = new Form2();                            newForm.Show(); //弹出主窗体                            
                            break;
                        case "1":
                            Form3 f3 = new Form3();                            f3.Show(); //弹出主窗体                            
                            break;
                        case "2":
                            Form1 f1 = new Form1();
                            f1.Show(); //弹出主窗体
                            break;
                            
                                                }
      点击登录按钮没有任何反应,是怎么回事?请大侠们帮帮忙

解决方案 »

  1.   

     switch ("select 权限 from dbo.工作微博 where 姓名='" + this.textBox1.Text + "'")
    你这个是固定值啊,你这样写咋 switch判断啊
      

  2.   

    就是这个原因~~~~
    把你reader的数据拿来switch
    switch (reader[0])
      {  
    }
      

  3.   

    if (reader.Read()) //如果找到用户信息,说明登录成功
      {    
      switch ("select 权限 from dbo.工作微博 where 姓名='" + this.textBox1.Text + "'")
      {  
    这边设断点看看能不能进去吧