private void button1_Click(object sender, System.EventArgs e)   //用户登录确定按钮
        {
            //激活menuItem2控件
            
            /////////////////////////////////////////// 与数据库进行连接,进行用户登录
            ///
             if(textBox2.Text!="")
             {
                 Form1 mainform =(Form1)this.Owner;
                 conn.Open();   //与数据库连接
                 SqlCommand com=new SqlCommand("select*from [user_guest] where [id]='"+comboBox1.Text+"'",conn);
                 SqlDataReader reader;
                 reader=com.ExecuteReader();
                 if(reader.Read())
                 {
                     if(textBox2.Text==reader["password"].ToString().Trim())//核对密码 
                     {
                         s=comboBox1.Text;  
                         if(char.Parse(reader["id"].ToString())== 0) //权限
                         {
                            
                             mainform.menuItem2.Enabled = true;
                             mainform.menuItem3.Enabled = true;
                             mainform.menuItem4.Enabled = true;
                             mainform.menuItem5.Enabled = true;
                             this.Close();
                             
                         }
                         
                        
                     }
                     else
                     {
                         MessageBox.Show("您输入的用户名或密码错,误请重新输入!","密码提示");
                         textBox2.Text="";
                         textBox2.Focus();
                     }
                 }
                 conn.Close();
             }
             else
             {
                 MessageBox.Show("请输入密码!");
                 textBox2.Focus();
             }
            
        }
        public string GetComboText()   //获取用户名函数
        {
            return s;
        }
        
    } 
抱错:   "未处理的“System.FormatException”类型的异常出现在 mscorlib.dll 中
其他信息:字符串的长度只能为一个字符" 怎么会这样!



 
											





 
	    

 
	




