首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

检测到不能访问代码解决思路

2012-01-24 
检测到不能访问代码publicpartialclassfrmLogin:Form{//publicstaticboolblCanLoginfalsepublicstaticst

检测到不能访问代码
public   partial   class   frmLogin   :   Form
        {
                //   public   static   bool   blCanLogin   =   false;
                  public   static   string   strUser   =   " ";
                  private   DataSet   ds   =   new   DataSet();
                  private   DataTable   myTable;
                  private   DataRow   myRow;
                  private   string   sendStrSQL   =   "select   *   from   LoginPwd ";//   where   Name= "+this.textBox1.Text();

                public   frmLogin()
                {
                        InitializeComponent();

                        DataBase   db   =   new   DataBase();
                        string   sendTableName   =   "LoginPwd ";
                        this.ds   =   db.SelectDataBase(sendStrSQL,sendTableName);
                        this.myTable   =   ds.Tables[0];
                        this.TopMost   =   true;
                }

                private   void   button2_Click(object   sender,   EventArgs   e)
                {
                        Application.Exit();
                }

                private   void   button1_Click(object   sender,   EventArgs   e)
                {
                        for   (int   i   =   0;   i   <   myTable.Rows.Count;   i++)       //这个提示检测到不能访问代码
                        {
                                this.myRow   =   myTable.Rows[i];
                                if   (myRow[0].ToString().Trim()   ==   this.textBox1.Text.ToString().Trim()   &&   myRow[1].ToString().Trim()   ==   this.textBox2.Text.ToString().Trim())
                                {
                                        MessageBox.Show( "legal   user ");


                                        this.Close();
                                        return;
                                }
                                else
                                {
                                        MessageBox.Show( "illegal   user ");
                                        Application.Exit();
                                        return;
                                }
                        }
                       
                       
                }
        }


请问一下是什么原因啊,我弄啊半天都没有弄出来

[解决办法]
myRow[0].试改为myRow[i][0]帐户,密码myRow[i][1]
[解决办法]
myRow[0]你这个都是判断第一个的。。应该要改为i了。不然你的循环都没用了。

热点排行