Home All Groups Group Topic Archive Search About

Finding Records in a Typed DataSet

Author
30 Jun 2006 8:35 PM
KarenP
Hi,

I have a typed DataSet and I am having a problem with one of the tables in
my DataSet.  The primary key on this table is defined by two fields: one is a
byte[] and the other a DateTime.  I am experiencing two problems, one I've
worked around and the other not.

Problem 1:

When reading data into my DataTable, I get get a ConstraintException if the
DateTime value in one of the rows equals the DateTime value in another row. 
The byte[] values are unique.  I have worked around this problem by setting
EnforceContstraints=false on the DataSet, but this still doesn't seem right
to me. 

Problem 2:

I am trying to use the
typedDataset.MyDataTable.FindByprimarykeyfields(byte[], DateTime) method to
retrieve a single record from my DataTable.  The method works great if the
DateTime value I pass is unique in the table.  If the DateTime value is not
unique, then the first record with that value is returned, regardless of the
value of my byte[] parameter (which IS unique). 

In trying to work around this problem I tried calling the generic
DataTable.Rows.Find(object[]) method and got the same results. 

I also tried redefining my primary key to only be the byte[] field.  I then
called typedDataset.MyDataTable.findByprimarykey(byte[]).  The result is that
every time I called this method, the first record in the table was returned,
regardless of the value of the byte[] parameter.

I'm starting to suspect that something is going on when a byte[] field is
defined as part of the primary key.

Any ideas?  I'm using .NET 1.1.

Thanks!

-Karen

AddThis Social Bookmark Button