none
C# winform 生成树遇到问题。 RRS feed

  • 问题

  •     string cmdsql = "select st_pattern,st_godate from dingdan group by st_pattern,st_godate order by st_pattern,st_godate";
        string cmdsqla = "select st_zhuti from style_dapei group by st_zhuti order by st_zhuti";
        string cmdsqlb = "select st_zhuti,st_godate from style_dapei group by st_zhuti,st_godate order by st_zhuti,st_godate";
        string cmdsqlc = "select st_zhuti,st_godate,st_xl from style_dapei group by st_zhuti,st_godate,st_xl order by st_xl";
    
        conn.Open();
          da = new SQLiteDataAdapter(cmdsqla, conn);
          db = new SQLiteDataAdapter(cmdsqlb, conn);
          dc = new SQLiteDataAdapter(cmdsqlc, conn);
          da.Fill(ds, "OneTree");
          db.Fill(ds, "TwoTree");
          dc.Fill(ds, "ThreeTree");
          conn.Close();
          for (int i = 0; i < ds.Tables["OneTree"].Rows.Count; i++)
          {
            this.DPeiTView.Nodes.Add("" + ds.Tables["OneTree"].Rows[i][0].ToString() + "");
            for (int j = 0; j < ds.Tables["TwoTree"].Rows.Count; j++)
            {
              if (ds.Tables["TwoTree"].Rows[j][0].ToString() == ds.Tables["OneTree"].Rows[i][0].ToString())
              {
                this.DPeiTView.Nodes[i].Nodes.Add("" + ds.Tables["TwoTree"].Rows[j][1].ToString() + "");
                for (int k = 0; k < ds.Tables["ThreeTree"].Rows.Count; k++)
                {
                  //if ((ds.Tables["TwoTree"].Rows[j][0].ToString() == ds.Tables["OneTree"].Rows[i][0].ToString() && ds.Tables["OneTree"].Rows[i][0].ToString() == ds.Tables["ThreeTree"].Rows[k][0].ToString()) && (ds.Tables["ThreeTree"].Rows[k][0].ToString() == ds.Tables["TwoTree"].Rows[i][0].ToString()) && (ds.Tables["ThreeTree"].Rows[k][1].ToString() == ds.Tables["TwoTree"].Rows[j][1].ToString()))
                  if ((ds.Tables["ThreeTree"].Rows[k][0].ToString() == ds.Tables["TwoTree"].Rows[j][0].ToString()) && (ds.Tables["ThreeTree"].Rows[k][1].ToString() == ds.Tables["TwoTree"].Rows[j][1].ToString()))
                  {
                    this.DPeiTView.Nodes[i].Nodes[j].Nodes.Add("" + ds.Tables["ThreeTree"].Rows[k][2].ToString() + "");
                  }
                }
              }
            }
          }

    用DataSet中的三个表循环生成树的时候,报错:

    报错如下:

    指定的参数已超出有效值的范围。
    参数名: index

     

    请大家指点下!该怎么解决这个问题!非常感谢!


    hi,this is paul!
    2011年2月12日 8:01

答案

全部回复