There is no row at position 447: Cannot fill in a DataTable

I have a DataTable which is filled with rows from a data stream. I Add a row each time a new complete set of field values becomes available. There are 6 fields in rows: three float, one int, one DateTime and one string (rather short, about 4 bytes).

After I streamlined my code to eliminate massive losses of data now the process is working fast. All of a sudden I get an error message: There is no row at position 468.

I put a Console.WriteLine statement in the routine which handles filling the rows (individually, one by one). Row 469 was created and then the message appeared.

In fact when I repeat the runs it breaks down at slighly different rows at each run. Also I have a button which I press. It creates a socket, send a request to a server and receives the data. If I ignore the error message There is no row at position ... the application is not closed but the connection is apparently lost. I can click my start button again and get another portion of 469 rows (if it broke down at 468 first time). Thus the whole picture will look like this:

broke at 468 --> 469 were created
broke at 937 --> 938 were created
broke at 1406 --> 1407 were created.

You can see that each time it is able to add 469 rows and cannot find the previous row to fill in data. If I close the application down and bring it up again, then the breakdown will happen most likely at a different row, e.g. at 473:

broke at 473 --> 474 were created
broke at 947 --> 948 were created
broke at 1418 --> 1419 were created.

Each time it adds precisely the same number of rows as the first batch not more not less.

Now I want to show the code that does it:
sqlTicksTab.Rows.Add ();
try
{
sqlTicksTab.Rows[sqlTicksTab.Rows.Count - 1].ItemArray.SetValue ( L1HistoryQuote.Bid, 0 );
// almost identical statements removed ...........
Console.WriteLine ( "row: {0} ", sqlTicksTab.Rows.Count );
}

Then I changed the first statement as follows:
sqlTicksTab.Rows.Add (sqlTicksTab.NewRow () );

After that I was able to fill in more rows at each attempt but still did not reach the endpoint:
broke at 521 --> 522 were created
broke at 1043 --> 1044 were created
broke at 1561 --> 1562 were created.

What is the reason for that I cannot work like this.
What shall I do

Thanks.




Answer this question

There is no row at position 447: Cannot fill in a DataTable

  • Mario Saccoia

    James Curran wrote:

    How 'bout we try:



    try
    {
    DatRow dr = sqlTicksTab.NewRow();
    dr[0] = L1HistoryQuote.Bid;
    // almost identical statements removed ...........
    sqlTicksTab.Rows.Add (dr);
    Console.WriteLine ( "row: {0} ", sqlTicksTab.Rows.Count );
    }

    Thank you James,

    I just noticed another big problem. NO VALUES are assigned to the fields (columns) in the rows, although the values in the struct are all there. Thus I end up with default values in all rows. What is the reason for that

    Before I cleared up this immdediate problem with empty rows I cannot try your code: it makes little sense.

    I most likely will be able to continue only tomorrow.



  • Loonyjuice

    James Curran wrote:

    Is the column structure in sqlTicksTab already set up

    Yes, it is.

    Well, actually you've won. The whole thing is working flawlessly now! It turns out there was no problem even in the first place. The only problem was the empty (default values) fields which has been killed by the way your code handled the new rows or rather addition of new rows.

    This is the whole story. I got back to it today and ran the debug. It broked down at 240 or somethig. It made me think. I am working with a demo that I downloaded from a reputable website and they said that the demo was OK, they said that there were problems with a C++ variant of the demo and this is why I chose C# for this app. The demo accepts a stream from a socket and parses it into records (not my records but some sort binary records). The first two bytes are record IDs. When I request a certain type of data I get, let say, 480 such records whose fields I convert to double, datetame, etc. But the last record is the "History End Record" which has a different ID and in the demo switch construct there was a bug as I found out. This record was directed into the usual parse normal record routine and it tried to find a row in my DataTable to put it in. Naturally, there was no row.

    It is the happy ending.

    Thank you for your help.



  • s441

    Well, actually you've won.

    Well, I've never thought of answer questions here as a win/lose proposal......



  • clint 2

    AlexBB wrote:
    James Curran wrote:

    Thank you James,

    I just noticed another big problem. NO VALUES are assigned to the fields (columns) in the rows, although the values in the struct are all there. Thus I end up with default values in all rows. What is the reason for that

    Before I cleared up this immdediate problem with empty rows I cannot try your code: it makes little sense.

    I most likely will be able to continue only tomorrow.

    James, MANY thanks,

    Your code did solve the SECOND problem. The data now ARE in the table, but not the first one! Is it not weird

    Your code when implemented did improve things! It now breaks down in the seventh handred! Thus you helped me to fill in 650 rows and I've begun with only 457 or so. We are making progress:)

    Thaks.



  • WalangAlam

    I just tred these statements:

    if ( sqlTicksTab.MinimumCapacity - sqlTicksTab.Rows.Count < 1000)
    sqlTicksTab.MinimumCapacity += 1000;

    No effect.



  • Sql4088

    Is the column structure in sqlTicksTab already set up



  • New-Bee

    How 'bout we try:



    try
    {
    DatRow dr = sqlTicksTab.NewRow();
    dr[0] = L1HistoryQuote.Bid;
    // almost identical statements removed ...........
    sqlTicksTab.Rows.Add (dr);
    Console.WriteLine ( "row: {0} ", sqlTicksTab.Rows.Count );
    }



  • There is no row at position 447: Cannot fill in a DataTable