473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

ADO.NET No Row At Position X Error

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();

Nov 17 '05 #1
4 2467
It would help if you told as what line the error occured on ....
<wa********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.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();

Nov 17 '05 #2
I am not sure, but I believe it occurs when the record is modified.

row["runTime"] = dt;

Nov 17 '05 #3
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)

Nov 17 '05 #4
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"];

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Felix Natter | last post by:
hi, I have a structure like: <topic name="xxx"> <subtopic name="subxxx"> <subsubtopic name="subsubxxx"> </subsubtopic> </subtopic> </topic>
8
by: Jaime Rios | last post by:
Hi, I created a COM AddIn for Word that performs the functions that it needs to, but I needed to add the ability for the toolbar created by the COM AddIn to remember it's last position and...
2
by: Jessard | last post by:
Hi All, I am writing a .NET app that accesses an access View. The view has a table column called 'Position'. When i try and right an UpdateCommand string for this using this column I am...
2
by: Senthil | last post by:
Hi, The need is to read each line in a text file and based on the read data decision has to be taken whether to reposition the file pointer. The StreamReader.Position does not give current...
6
by: KJ | last post by:
How can you look for a character in a certain position with VB.Net and if the string length is less than the position have it return and empty string instead of an error? Substring returnns an...
2
by: Troels Arvin | last post by:
Hello, I'm working on a datatype which I call dnaseq. The basic stuff like input/output functions, comparison operators, etc., work well. I have overloaded the CHARACTER_LENGTH function...
2
by: petermichaux | last post by:
Hi, It seems like determining element position in a web page is a difficult task. In the position reporting source code I've looked at there are special fixes for at least some versions of...
2
by: romain.larmet | last post by:
Hi all, I need to get the mouse cursor's position using JavaScript. Until now, everything was working well in IE, FF and Opera using the event.clientX/Y and e.pageX/Y members, depending on which...
5
by: sheldonlg | last post by:
BootNic wrote: Thanks. That worked on all three browsers. Now I have a problem putting it into my real app. First, I put the javascript into a separate file. I also put the css stuff...
5
by: Andrus | last post by:
I use Winforms RichTextBox control to edit scripts. Scripts are plain ascii texts. When error occurs, script engine returns character position of error in code as integer. How to position...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.