473,563 Members | 2,916 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 3387
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
2100
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...
1
2229
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...
2
11144
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...
1
2963
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...
0
3131
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...
4
5660
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). ...
1
5724
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
1764
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
7664
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...
0
7583
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...
0
7885
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. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
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...
1
2082
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 we have to send another system
0
923
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...

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.