473,498 Members | 1,648 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 _executionMonitor
exec = _tradeTable.NewRow
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.Collections.ArrayList.get_Item(Int32 index)
at System.Data.RecordManager.NewRecordBase()
at System.Data.DataTable.NewRecord(Int32 sourceRecord)
at System.Data.DataTable.NewRow(Int32 record)
at System.Data.DataTable.NewRow()
at LaBranche.Barracuda.TradeManager.OnEntryMessageRec eived(Object sender, MessageEventArgs e))
Any thoughts are appreciated. Thanks.

- Jason
Jul 21 '05 #1
7 3374
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*******@hotmail.com> schreef in bericht
news:uS**************@TK2MSFTNGP12.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 _executionMonitor
exec = _tradeTable.NewRow
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.Collections.ArrayList.get_Item(Int32
index)
at System.Data.RecordManager.NewRecordBase()
at System.Data.DataTable.NewRecord(Int32 sourceRecord)
at System.Data.DataTable.NewRow(Int32 record)
at System.Data.DataTable.NewRow()
at LaBranche.Barracuda.TradeManager.OnEntryMessageRec eived(Object sender,
MessageEventArgs 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**********@planet.nl> wrote in message
news:Ot**************@TK2MSFTNGP10.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*******@hotmail.com> schreef in bericht
news:uS**************@TK2MSFTNGP12.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 _executionMonitor
exec = _tradeTable.NewRow
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.Collections.ArrayList.get_Item(Int32
index)
at System.Data.RecordManager.NewRecordBase()
at System.Data.DataTable.NewRecord(Int32 sourceRecord)
at System.Data.DataTable.NewRow(Int32 record)
at System.Data.DataTable.NewRow()
at LaBranche.Barracuda.TradeManager.OnEntryMessageRec eived(Object sender,
MessageEventArgs 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 _executionMonitor
exec = _tradeTable.NewRow
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.Collections.ArrayList.get_Item(Int32 index)
' at System.Data.RecordManager.NewRecordBase()
' at System.Data.DataTable.NewRecord(Int32 sourceRecord)
' at System.Data.DataTable.NewRow(Int32 record)
' at System.Data.DataTable.NewRow()
' at
LaBranche.Barracuda.TradeManager.OnEntryMessageRec eived(Object sender,
MessageEventArgs e))
End Try

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

- Jason

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.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.NewRow


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**********@planet.nl> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
Hi Jason,

It is very few code.
exec = _tradeTable.NewRow


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
2081
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 (...
1
2217
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...
2
11136
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...
1
2959
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...
0
3124
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...
4
5654
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: ...
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...
1
5705
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...
0
1759
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: ...
0
7005
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...
0
7168
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,...
0
7210
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5465
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,...
0
4595
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...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
293
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...

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.