Strongly Typed Dataset Table - Indexed Find returns Nothing

  • Thread starter Thread starter David Wender
  • Start date Start date
D

David Wender

I have a strongly typed dataset and use the "FindBy.." function to
search for a particular record based on the Primary Key.
Generally, this works fine, but every once in a while, the find
function fails and will not work anymore. In other words, when
searching for a particular record, the FindBy function returns nothing
even though the record definitely still exists. I have included some
items from the Watch List below:

_dstMain.FuturesContracts.Rows.Count 428 Integer

DirectCast(_dstMain.FuturesContracts.Rows(273),FuturesDataset.FuturesContractsRow).FuturesCode "NG
" String

DirectCast(_dstMain.FuturesContracts.Rows(273),FuturesDataset.FuturesContractsRow).FuturesContract "U04
" String

_dstMain.FuturesContracts.FindByFuturesCodeFuturesContract("NG
", "U04 ") Nothing

As you can see, the dataset has 428 rows and row 273 contains the
values "NG " for FuturesCode and "U04 " for
FuturesContract. The function FindByFuturesCodeFuturesContract returns
Nothing even though I am searching for a row that exists. (I also
tried searching with the trailing spaces trimmed, but that did not
help.)

This table is being updated very often, though rows never get deleted
or added.

I also noted that the table in question seems to have 10 indexes. When
the failure occurs, it seems to have 12 indexes, many with errors. I
don't know where these extra indexes are coming from but I assume that
they are part of the problem.

Any help would be greatly appreciated.

Thanks.

Dave.
 
David Wender said:
I have a strongly typed dataset and use the "FindBy.." function to
search for a particular record based on the Primary Key.
Generally, this works fine, but every once in a while, the find
function fails and will not work anymore. In other words, when
searching for a particular record, the FindBy function returns nothing
even though the record definitely still exists. I have included some
items from the Watch List below:

_dstMain.FuturesContracts.Rows.Count 428 Integer
.. . .

This table is being updated very often, though rows never get deleted
or added.

.. . .

The dataset is not thread-safe. You must manually prevent threads from
reading from the dataset while any other thread is updating it. A DataSet
has several sets of rows: Original, Updated, New, Deleted and as you update
the DataSet shuffeled around among these sets. So you need to lock the
DataSet throughout the sequence of operations from the update through the
AcceptChanges.

David

David
 
Thanks for your response.
That makes a lot of sense now. I'll try to lock up the dataset during
the updates as you suggest.

Dave.
 
Back
Top