DataRow [] dr=ds.Tables["tmp"].Select("ChannelId="+index+" And AccountId="+AccountId);
  if(dr.Length>0)
      this.TextBox1.Text=dr[3].ToString();请问为什么老是说   索引超出了数组界限。 啊!请达人帮忙!!!谢谢了!!!

解决方案 »

  1.   

    你可以先把index改成具体下标试下
      

  2.   

    if(dr.Length>0)
          this.TextBox1.Text=dr[3]///?????
    .ToString();
      

  3.   

    楼上的是这个意思吗?this.TextBox1.Text=dr[3]["ChannelName"].ToString();
      

  4.   

    下标从零开始,我的第四列有值啊。
    我写的SQL语句在查询分析器里也好使。
      

  5.   

    this.TextBox1.Text=dr[3]["ChannelName"].ToString();
    就是这行越界了。
    有哪位能把从DataSet里提取一行的正确写法贴出来看看。谢谢了。
      

  6.   

    if(dr.Length>=4)
          this.TextBox1.Text=dr[3].ToString();
      

  7.   

    写的不合理,把if(dr.Length>0)改为 if(dr.Length>4)
      

  8.   

    DataRow [] dr=ds.Tables["tmp"].Select("ChannelId="+index+" And AccountId="+AccountId);
      if(dr.Length>= 4)
          this.TextBox1.Text=dr[3]["字段名"].ToString();