Home All Groups Group Topic Archive Search About

ADO.NET No Row At Position X Error

Author
12 Apr 2005 12:40 PM
wackyphill
I keep getting this error on a scheduling program I'm working on and
don't know why. It seems to be the last row in the view always that
gets the error.

The Code W/ The Error:  (_db is a wrapper around some ADO Objects)


int       freq;
int       days;
DateTime  now      = DateTime.Now;
string    where    = string.Format("runTime <= '{0}'", now);
bool      bEnabled = false;
string    path     = null;
DataView  runView  = new DataView( _db.DS.Tables["task"], where, null,
DataViewRowState.CurrentRows);

foreach( DataRowView row in runView )
{
  //Pull Values
  freq     = (int)row["freq"];
  dt       = (DateTime)row["runTime"];
  days     = (int)row["days"];
  bEnabled = (bool)row["enabled"];
  path     = (string)row["path"];

  //Update Time For Task To Run Next
  if( freq == 0 ) { dt = dt.AddDays(1);       }
  else            { dt = dt.AddMinutes(freq); }
  row.BeginEdit();
  row["runTime"] = dt;
  row.EndEdit();

  //Test If Task Should Run Today
  int todayMask = (int)Math.Pow(2, (double)now.DayOfWeek);
  if( (todayMask & days) == 0 ) { continue; }

  //Run, If Enabled
  if( bEnabled ) { RunProcess( path ); }
}
_db.Task_ApplyChanges();
RefreshTasks();

Author
12 Apr 2005 2:51 PM
James Curran
It would help if you told as what line the error occured on ....


<wackyph***@yahoo.com> wrote in message
Show quoteHide quote
news:1113309643.047306.116140@g14g2000cwa.googlegroups.com...
> I keep getting this error on a scheduling program I'm working on and
> don't know why. It seems to be the last row in the view always that
> gets the error.
>
> The Code W/ The Error:  (_db is a wrapper around some ADO Objects)
>
>
> int       freq;
> int       days;
> DateTime  now      = DateTime.Now;
> string    where    = string.Format("runTime <= '{0}'", now);
> bool      bEnabled = false;
> string    path     = null;
> DataView  runView  = new DataView( _db.DS.Tables["task"], where, null,
> DataViewRowState.CurrentRows);
>
> foreach( DataRowView row in runView )
> {
>   //Pull Values
>   freq     = (int)row["freq"];
>   dt       = (DateTime)row["runTime"];
>   days     = (int)row["days"];
>   bEnabled = (bool)row["enabled"];
>   path     = (string)row["path"];
>
>   //Update Time For Task To Run Next
>   if( freq == 0 ) { dt = dt.AddDays(1);       }
>   else            { dt = dt.AddMinutes(freq); }
>   row.BeginEdit();
>   row["runTime"] = dt;
>   row.EndEdit();
>
>   //Test If Task Should Run Today
>   int todayMask = (int)Math.Pow(2, (double)now.DayOfWeek);
>   if( (todayMask & days) == 0 ) { continue; }
>
>   //Run, If Enabled
>   if( bEnabled ) { RunProcess( path ); }
> }
> _db.Task_ApplyChanges();
> RefreshTasks();
>
Are all your drivers up to date? click for free checkup

Author
12 Apr 2005 3:38 PM
wackyphill
I am not sure,  but I believe it occurs when the record is modified.

row["runTime"] = dt;
Author
12 Apr 2005 3:44 PM
wackyphill
This is the error. But I get no line #:


There is no row at position 3.
   at System.Data.DataView.GetRecord(Int32 recordIndex)
   at System.Data.DataView.IsOriginalVersion(Int32 index)
   at System.Data.DataRowView.get_Item(String property)
   at ScheduleManager.MainFrm.timer_Tick(Object sender, EventArgs e)
Author
12 Apr 2005 6:10 PM
wackyphill
OK Tried it in .NET 2.0b add it does show the line #.

Is happens when the row is accessed first.
--->   freq     = (int)row["freq"];

Bookmark and Share