Hi again!

I have a database and some tables filled with data.

var club = Baza.Clubs; //Baza is dataset, and Clubs is table
            var schedule = Baza.Schedule; // same as above

            for (int i = 1; i <= 90; i++)
            {
                if(schedule[i].day == 2) // BOOM! Breaks at first pass..
                {
                    //Do something..
                }
            }

When I run my app it throws me this error: There is no row at position 0
and throws me to dataSet.Designer.cs to this part of code:

public ScheduleRow this[int index] {
                get {
                    return ((ScheduleRow)(this.Rows[index]));
                }
            }

Any ideas why this happens?

Is Schedule null when it is assigned?

Sorry, not sure what you mean.. Where is it assigned? At 'var schedule = Baza.schedule'?

And btw, Baza.Clubs has 10 rows according to Locals, but Baza.Schedule does not have any..

Edited 4 Years Ago by niggz: n/a

var schedule = Baza.Schedule; // same as above
if(null == schedule)
{
   //Something is wrong before it got to here
}
var schedule = Baza.Schedule; // same as above
if(null == schedule)
{
   //Something is wrong before it got to here
}

No, thats okay..

Surely there is just a lack of rows in whatever you are pulling as you are looking for the row (2) so the third row in. Run a debug and use a break point to see what is contained within the schedule and see if that helps to solve the issue?

Im making assumptions but the error as Thines01 said could either be that it is null or that the schedule actually contains no rows.

Surely there is just a lack of rows in whatever you are pulling as you are looking for the row (2) so the third row in. Run a debug and use a break point to see what is contained within the schedule and see if that helps to solve the issue?

Im making assumptions but the error as Thines01 said could either be that it is null or that the schedule actually contains no rows.

I've been through locals, and it contains only columns, but no rows. I'm not sure why. Why do the other tables work properly?

Kind of impossible to tell from the information provided.

Common sense would say either the Baza.Schedule object doesnt contain anything row wise or there is a failing link in your database working somewhere preventing the rows being pulled?

Maybe give us a more extensive code post and an insight into the type of informaation that you should be expecting?

I managed to get it to work. The thing I changed was this:

var club = Baza.Clubs; //Baza is dataset, and Clubs is table
    var schedule = Baza.Schedule; // same as above
     
    for (int i = 0; i < schedule.count; i++) // THIS WAS REPLACED
    {
    if(schedule[i].day == 2)
    {
    //Do something..
    }
    }

AND MOST IMPORTANTLY... I added this in form load:

scheduleTableAdapter.Fill(Baza.schedule);

I had some database issues, so I had to delete it, and add again, and thats why this error was created. Thanks guys!

This question has already been answered. Start a new discussion instead.