473,806 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable and NewRow problem

I have a process that manages a list of trades. Each trade is a separate row in the table. I blast the process with 10,000 new trades in order to stress test it and end up with the below listed exception when I call the NewRow method. The number of times it happens is NOT consistent (sometimes a few times out of 10,000 and sometimes 1000+ times). The app is written in VB and I am using SyncLock everywhere the table is accessed but I am sure it is still some concurrency issue.
Code ==>

' create new execution row
SyncLock _executionMonit or
exec = _tradeTable.New Row
End SyncLock

Execption ==>

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index) ( at System.Collecti ons.ArrayList.g et_Item(Int32 index)
at System.Data.Rec ordManager.NewR ecordBase()
at System.Data.Dat aTable.NewRecor d(Int32 sourceRecord)
at System.Data.Dat aTable.NewRow(I nt32 record)
at System.Data.Dat aTable.NewRow()
at LaBranche.Barra cuda.TradeManag er.OnEntryMessa geReceived(Obje ct sender, MessageEventArg s e))
Any thoughts are appreciated. Thanks.

- Jason
Jul 21 '05 #1
7 3401
Hi Jason,

What is has the SyncLock to do with the concurrency problems.

A datatable is disconnected. It is not a recordset.

So you can add as much rows as you want except you can not create rows with
duplicated primary keys.

How do you add rows to your table, because it says that the index is/becomes
incorrect.

However maybe I miss something and than I am curious about that?

Cor

Hi
"Jason Callas" <Ja*******@hotm ail.com> schreef in bericht
news:uS******** ******@TK2MSFTN GP12.phx.gbl...
I have a process that manages a list of trades. Each trade is a separate row
in the table. I blast the process with 10,000 new trades in order to stress
test it and end up with the below listed exception when I call the NewRow
method. The number of times it happens is NOT consistent (sometimes a few
times out of 10,000 and sometimes 1000+ times). The app is written in VB
and I am using SyncLock everywhere the table is accessed but I am sure it is
still some concurrency issue.
Code ==>

' create new execution row
SyncLock _executionMonit or
exec = _tradeTable.New Row
End SyncLock

Execption ==>

Index was out of range. Must be non-negative and less than the size of the
collection.
Parameter name: index) ( at System.Collecti ons.ArrayList.g et_Item(Int32
index)
at System.Data.Rec ordManager.NewR ecordBase()
at System.Data.Dat aTable.NewRecor d(Int32 sourceRecord)
at System.Data.Dat aTable.NewRow(I nt32 record)
at System.Data.Dat aTable.NewRow()
at LaBranche.Barra cuda.TradeManag er.OnEntryMessa geReceived(Obje ct sender,
MessageEventArg s e))
Any thoughts are appreciated. Thanks.

- Jason
Jul 21 '05 #2
I am not sure if it is a synclock problem at all. (I do have more than one
thread using the tablem hence the use of synclock).

The problem is not when I add the row but when I go to create a new row. If
you look at the exception you see that it is being thrown internally to the
DataTable on the NewRow method.

- Jason

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
Hi Jason,

What is has the SyncLock to do with the concurrency problems.

A datatable is disconnected. It is not a recordset.

So you can add as much rows as you want except you can not create rows with duplicated primary keys.

How do you add rows to your table, because it says that the index is/becomes incorrect.

However maybe I miss something and than I am curious about that?

Cor

Hi
"Jason Callas" <Ja*******@hotm ail.com> schreef in bericht
news:uS******** ******@TK2MSFTN GP12.phx.gbl...
I have a process that manages a list of trades. Each trade is a separate row in the table. I blast the process with 10,000 new trades in order to stress test it and end up with the below listed exception when I call the NewRow
method. The number of times it happens is NOT consistent (sometimes a few
times out of 10,000 and sometimes 1000+ times). The app is written in VB
and I am using SyncLock everywhere the table is accessed but I am sure it is still some concurrency issue.
Code ==>

' create new execution row
SyncLock _executionMonit or
exec = _tradeTable.New Row
End SyncLock

Execption ==>

Index was out of range. Must be non-negative and less than the size of the
collection.
Parameter name: index) ( at System.Collecti ons.ArrayList.g et_Item(Int32
index)
at System.Data.Rec ordManager.NewR ecordBase()
at System.Data.Dat aTable.NewRecor d(Int32 sourceRecord)
at System.Data.Dat aTable.NewRow(I nt32 record)
at System.Data.Dat aTable.NewRow()
at LaBranche.Barra cuda.TradeManag er.OnEntryMessa geReceived(Obje ct sender,
MessageEventArg s e))
Any thoughts are appreciated. Thanks.

- Jason

Jul 21 '05 #3
Hi Jason,
The problem is not when I add the row but when I go to create a new row. If you look at the exception you see that it is being thrown internally to the DataTable on the NewRow method.

That is as I said, however some code how you create a new row can show a lot
How do you add rows to your table, because it says that the index is/becomesincorrect.


With that I did mean show us some code where the new row is created and
added..
(and not more, this should normally be enough)

Cor
Jul 21 '05 #4
I did in the first posting but here it is again.

I have been unable to create a small application that can reproduce the
problem (for posting purposes). There are libraries that are used to submit
the trade (via thrid party middleware) and others that are used to validate
that cannot be posted.

I did put a try/catch block around just the NewRow method that was causing
the exception to confirm that it was the code inside DataTable that was the
problem.

Try
SyncLock _executionMonit or
exec = _tradeTable.New Row
End SyncLock
Catch ex as Exception
' sometimes the above code causes an exception
' Index was out of range. Must be non-negative and less than the
size of the collection.
' Parameter name: index) ( at
System.Collecti ons.ArrayList.g et_Item(Int32 index)
' at System.Data.Rec ordManager.NewR ecordBase()
' at System.Data.Dat aTable.NewRecor d(Int32 sourceRecord)
' at System.Data.Dat aTable.NewRow(I nt32 record)
' at System.Data.Dat aTable.NewRow()
' at
LaBranche.Barra cuda.TradeManag er.OnEntryMessa geReceived(Obje ct sender,
MessageEventArg s e))
End Try

Sorry I cannot provide more info but maybe somebody else has run into this
problem.

- Jason

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi Jason,
The problem is not when I add the row but when I go to create a new row. If
you look at the exception you see that it is being thrown internally to

the
DataTable on the NewRow method.

That is as I said, however some code how you create a new row can show a

lot
How do you add rows to your table, because it says that the index is/becomesincorrect.


With that I did mean show us some code where the new row is created and
added..
(and not more, this should normally be enough)

Cor

Jul 21 '05 #5
Hi Jason,

It is very few code.
exec = _tradeTable.New Row


This is your code with what you create a new table in your datatable?

What is exec?

Cor
Jul 21 '05 #6
Its a DataRow of course. (NewRow method of DataTable class only returns
DataRow objects.)

But nevermind on the whole thing. If you have not experienced this problem
you will not figure it out....

I am just going to change everything and use hashtables and arraylists.

- Jason
"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Hi Jason,

It is very few code.
exec = _tradeTable.New Row


This is your code with what you create a new table in your datatable?

What is exec?

Cor

Jul 21 '05 #7
Hi Jason,

Maybe you are right, maybe can this help you some messages about the datarow
in the dotnet newsgroups
..
http://groups.google.com/groups?q=da...sa=G&scoring=d

Cor

But nevermind on the whole thing. If you have not experienced this problem
you will not figure it out....

Jul 21 '05 #8

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

Similar topics

4
2114
by: David K | last post by:
we are having a problem when trying to serilalize and deserialize DataTable When replacing the container to be ListArray or HashTable everything works fine The code is very straight forward ( see below), however when comparing the DataTable before and after the serialize, it is not the same The DataTable after the serialization contains only the string of class type ( Vclass in this class) but not the class itself Any idea ?
1
2247
by: Al Bastido via .NET 247 | last post by:
could somebody please explain to me how the datatable.newrow method works, i've been trying to figure it out for weeks. I need to emulate it myself. I can bind my datagrid to a collection of objects with no problem. But that leaves me with a fixed number of properties per object and therefore a fixed number of columns in my datagrid. I wanted to do something similar to the datatable, where you add columns then have a method that generates...
2
11152
by: Newbie | last post by:
Im getting an exception: System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ToInt32(Object value) at System.Data.Common.Int32Storage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <BILLABLE...
1
2974
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in a DataGrid, and set the PrimaryKey of the DataTable to be the first cell in the grid (which is a UserID value). I then store the DataTable in a session object, from which it is retrieved for subsequent pages. All this seems to be working fine. ...
0
3169
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what I am doing. User enters values into an asp.net form and clicks a button. Retrieve dataset from...
4
5672
by: VK | last post by:
Hello, I have a dataset which has one datatable in it. The dt has over 3000 rows in it. Now I would like to get the rows where the StartDate is 15 Feb 2005, so I did the following: ds.Tables(0).Select("StartDate = '15/02/2005'") However this returns me only 3 rows. I have tried other possiblities like:
7
414
by: Jason Callas | last post by:
I have a process that manages a list of trades. Each trade is a separate row in the table. I blast the process with 10,000 new trades in order to stress test it and end up with the below listed exception when I call the NewRow method. The number of times it happens is NOT consistent (sometimes a few times out of 10,000 and sometimes 1000+ times). The app is written in VB and I am using SyncLock everywhere the table is accessed but I am sure it...
1
5742
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the work manually. I am looking for an automated way. Thank you, Max
0
1774
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: //=================================================================== // The table
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.