There is no row at position 0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uday1302
    New Member
    • Mar 2008
    • 18

    There is no row at position 0

    Hi Friends,
    There is no row at position 0 Error
    here it is my code..
    [code=cpp]
    string q="select * from Masters where deptno="+deptno ;
    dataset ds=new datset();
    sqldataadapter da=new sqldatadapter(q , conn);
    da.fill(ds,"fil l");
    listviewitem list=null;
    foreach(datarow dr in ds.tables["fill"].rows)
    {
    list=new lisviewitem(dr. rows["empno"].tostring());
    listview.items. add(list);
    list.subitems.a dd(dr.rows["empname"].tostring())
    }[/code]
    In masters tables row values r ther.
    deptno, empno emname
    1 100 u
    2 200 k
    3 null null
    4 null op
    if i select deptno 1 values r retrived...if i select deptno 3 then tht error exists
    Please me how to solve the problem. I think everbody understood
  • uday1302
    New Member
    • Mar 2008
    • 18

    #2
    Plz reply me Guys i am in very urgent

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by uday1302
      Plz reply me Guys i am in very urgent
      You posted that in the wrong forum.
      This is certainly not a programming challenge.
      You get responses faster if you post in the correct forum.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by uday1302
        Hi Friends,
        There is no row at position 0 Error
        here it is my code..
        [code=cpp]
        string q="select * from Masters where deptno="+deptno ;
        dataset ds=new datset();
        sqldataadapter da=new sqldatadapter(q , conn);
        da.fill(ds,"fil l");
        listviewitem list=null;
        foreach(datarow dr in ds.tables["fill"].rows)
        {
        list=new lisviewitem(dr. rows["empno"].tostring());
        listview.items. add(list);
        list.subitems.a dd(dr.rows["empname"].tostring())
        }[/code]
        In masters tables row values r ther.
        deptno, empno emname
        1 100 u
        2 200 k
        3 null null
        4 null op
        if i select deptno 1 values r retrived...if i select deptno 3 then tht error exists
        Please me how to solve the problem. I think everbody understood
        I'm not sure what you are doing in the Selected Index Changed event for your ListView....may be you're not properly referencing the correct index?

        Could you please post your code for this method so that we can better understand your problem. Remember to use [code] tags when posting code.

        -Frinny

        Comment

        • GayathriP
          New Member
          • Oct 2007
          • 17

          #5
          Hi Uday,

          The line
          Code:
          list=new lisviewitem(dr.rows["empno"].tostring());
          should be

          Code:
          list=new lisviewitem(dr["empno"].tostring());
          <B>The Datarow object doesn't have the rows collection</B>

          Hope now it will work.

          Comment

          Working...