|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ADO.NET No Row At Position X Errordon'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(); 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(); > I am not sure, but I believe it occurs when the record is modified.
row["runTime"] = dt; 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)
Other interesting topics
Wrong overload resolution ?
void parameter argument Send message like Yahoo Messenger?? elements(list view) Capturing Close Events General question about C# SEARCH XML ATTRIBUTE BASED ON THE VALUE OF ANOTHER ATTRIBUTE How to bring an Instance of IEExplorer when the user insert my application cd inside the CD RoM Regular expression for validate Adding a service description |
|||||||||||||||||||||||