Can a DataTable have foreign keys?

G

Guest

I love the feature of DataTable to specify a Primary Key and then be able to
search by it using the Rows.Find method...

but is there a way to do this for a foreign or alternate key- i.o.w. to be
able to search in a specific column besides the Primary Key column(s) ??
 
J

John Wood

Use the "select" method to do this, where you'd pass in an expression such
as "myfield = 14".
Keep in mind that every select you run, it will be faster the second time -
the first time it builds an index in a hashtable automatically. The index is
deleted when any of the rows are updated. Alternatively you can use the
AddIndex and RemoveIndex (IBindingList methods) to set up the indexes before
the select. Hope that helps.
 

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

Top