Tactics of reading a specific record?

  • Thread starter Thread starter Barfy the Wonder Camel
  • Start date Start date
B

Barfy the Wonder Camel

I've loaded a dataset from an access database, and now I want to find
a specific record in a datatable that's part of that dataset. First, I
was surprised to find that the Find() method complains that there's no
primary key on the datatable, even though I've checked 3 times that
there is a primary key on the access table. So either Access PKs don't
translate well, or you always have to explicitly define the PKs in a
datatable after reading it. Either one seems odd, but what do I know?

Anyway, given this, what's the best way to get a specific record?
Creating a new datatable just to get a record seems overkill, having
to explicitly define the pk's is a lot of work, and using the
DataTable.Select() function brings its own set of problems. I could
just sequentially search through the Rows..... :-)

Strangely, the book (Microsoft Visual C# 2005 Step by Step) is silent
on this subject. So..... suggestions?

BTW, if I go with Select, I've already noted that I'll have the hassle
of allowing for quotes and special characters in my parameters, and I
haven't found a way to parameterize the select string.

[Sigh] This is one of those cases where I could go down any one of
several paths, and each would work, but I may find out later that I've
shot myself in the foot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top