473,322 Members | 1,610 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,322 software developers and data experts.

datarow updates: slow?

hi all,

my code currently reads as the following:

//////

double tmpposition = (double)dr["position"] + pos;

dr["position"] = tmpposition;

//////

where dr is a DataRow and pos is of type double. however it seems that the
second line takes quite a while to execute - around a quarter of a second.
however, adding new rows to the table in which the row resides is quick, as
is selecting etc.

am i updating the row value incorrectly?

tia!

spammy
Jul 21 '05 #1
3 1729
Hi Spammy,

Is your row bound to some UI control perhaps?
Are there any other factors involved?
Normally it should be a breeze...

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"spammy" <me@privacy.net> wrote in message
news:2g************@uni-berlin.de...
hi all,

my code currently reads as the following:

//////

double tmpposition = (double)dr["position"] + pos;

dr["position"] = tmpposition;

//////

where dr is a DataRow and pos is of type double. however it seems that the
second line takes quite a while to execute - around a quarter of a second.
however, adding new rows to the table in which the row resides is quick, as is selecting etc.

am i updating the row value incorrectly?

tia!

spammy

Jul 21 '05 #2
Miha,

its a command line app, so no UI controls. ive tried to make the code as
brief as possible for simplicity, but obviously that may have hidden the
problem too.

more code:

DataRow[] targets = result.Select("ColA = '" + ColA + "' AND ColB = '" +
ColB + "' AND ColC = '" + ColC + "' AND ColD = '" + ColD+ "'");

if (targets.Length == 0)

{

//none exist - set up row

string secname = getSecName(secid, prices);

result.Rows.Add(new object[] {ColA, ColB, ColC, ColD, name, pos, p,
change});

}

else if (targets.Length == 1)

{

//amend exisitng

double tmpposition = (double)targets[0]["position"] + pos;

targets[0]["position"] = tmpposition;

}

else

{

throw new Exception("Too many entries found in table!!");

}
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:eW*************@TK2MSFTNGP10.phx.gbl...
Hi Spammy,

Is your row bound to some UI control perhaps?
Are there any other factors involved?
Normally it should be a breeze...

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"spammy" <me@privacy.net> wrote in message
news:2g************@uni-berlin.de...
hi all,

my code currently reads as the following:

//////

double tmpposition = (double)dr["position"] + pos;

dr["position"] = tmpposition;

//////

where dr is a DataRow and pos is of type double. however it seems that the second line takes quite a while to execute - around a quarter of a second. however, adding new rows to the table in which the row resides is quick,

as
is selecting etc.

am i updating the row value incorrectly?

tia!

spammy



Jul 21 '05 #3
Hi,

Try executing the problematic code in a loop so you'll eliminate the "first
hit" issue.
If you don't have a profiler handy, place a timing code before and after,
i.e.
DateTime start = DateTime.Now;
.....
TimeSpan elapsed = DateTime.Now-start;

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"spammy" <me@privacy.net> wrote in message
news:2g************@uni-berlin.de...
Miha,

its a command line app, so no UI controls. ive tried to make the code as
brief as possible for simplicity, but obviously that may have hidden the
problem too.

more code:

DataRow[] targets = result.Select("ColA = '" + ColA + "' AND ColB = '" +
ColB + "' AND ColC = '" + ColC + "' AND ColD = '" + ColD+ "'");

if (targets.Length == 0)

{

//none exist - set up row

string secname = getSecName(secid, prices);

result.Rows.Add(new object[] {ColA, ColB, ColC, ColD, name, pos, p,
change});

}

else if (targets.Length == 1)

{

//amend exisitng

double tmpposition = (double)targets[0]["position"] + pos;

targets[0]["position"] = tmpposition;

}

else

{

throw new Exception("Too many entries found in table!!");

}
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:eW*************@TK2MSFTNGP10.phx.gbl...
Hi Spammy,

Is your row bound to some UI control perhaps?
Are there any other factors involved?
Normally it should be a breeze...

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"spammy" <me@privacy.net> wrote in message
news:2g************@uni-berlin.de...
hi all,

my code currently reads as the following:

//////

double tmpposition = (double)dr["position"] + pos;

dr["position"] = tmpposition;

//////

where dr is a DataRow and pos is of type double. however it seems that the second line takes quite a while to execute - around a quarter of a second. however, adding new rows to the table in which the row resides is
quick, as
is selecting etc.

am i updating the row value incorrectly?

tia!

spammy



Jul 21 '05 #4

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

Similar topics

0
by: Chloe Crowder | last post by:
Hi we have a third party application (Adobe Content Server) which regularly stalls (and times out) during testing. Profiler indicates the statement which sometimes times out is updating a table...
8
by: Rodusa | last post by:
I am getting an error on line 133. I am trying to update a datarow using the find method, but it keeps throwing the error below: int ItemKey = dv.Find(Item.inv_mast_uid); DataRow dr; if...
4
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out...
4
by: Agnes | last post by:
My form got over 30 textbox, some textbook suggest to use Bindingcontext method. to addnew/update. However, some other box didn't mention 'bindingcontext', it gives me a simple sample by using...
5
by: rodchar | last post by:
Hey all, I thought what I was doing was pretty straightforward but apparently not. All I'm doing is loading a datarow, letting the user modify a field in the datarow by inputing into a textbox....
3
by: spammy | last post by:
hi all, my code currently reads as the following: ////// double tmpposition = (double)dr + pos; dr = tmpposition;
10
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
2
by: rn5a | last post by:
When a DataGrid is in the editable mode, users can change the quantity of the items that are currently in his shopping cart by entering a new quantity in a TextBox. After changing the quantity, a...
6
by: cj | last post by:
If I'm sitting on a datarow for a customer and want to change his phone number only if it's blank what would I write? if myDr("phone")= "" then myDr("phone") = "mphone" endif...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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.