finding primary keys in visual basic .net

X

xyious

i need to do the above....

i need to figure out which column has the primary key, if any, in the
current table, or all tables.... any way to find out would be good...
 
6

'69 Camaro

Hi.
i need to figure out which column has the primary key, if any, in the
current table, or all tables

This newsgroup is dedicated to Microsoft Access database questions. I
suggest you post your question about VB .Net programming in a VB .Net
newsgroup, because Access's VBA programming language won't work in your
programming IDE.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
X

xyious

Hi.


This newsgroup is dedicated to Microsoft Access database questions. I
suggest you post your question about VB .Net programming in a VB .Net
newsgroup, because Access's VBA programming language won't work in your
programming IDE.

actually it would help me since i could at least try to figure out how
to do the same thing in my IDE.
but still, most VB/.net programming forums/newsgroups rarely have
access threads and even rarer have actual answers to the questions i
have....
 
6

'69 Camaro

Hi.
actually it would help me since i could at least try to figure out how
to do the same thing in my IDE.

Set a reference to the DAO library, then iterate through the Indexes
Collection of each TableDef, and check the Primary Property of the Index
object. If it's TRUE, then check which columns that Index object contains.
Those will be all of the columns of the primary key, even if it's a
composite primary key.
most VB/.net programming forums/newsgroups rarely have
access threads and even rarer have actual answers to the questions i
have....

When using VB .Net, it generally takes three to five times longer to program
the equivalent built-in Access features and VBA capabilities. If you're
programming an Access database, then the recommended method is to use
Access, because Access's RAD environment so much quicker and cheaper to
develop with when an experienced developer is using it.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
X

xyious

Hi.


Set a reference to the DAO library, then iterate through the Indexes
Collection of each TableDef, and check the Primary Property of the Index
object. If it's TRUE, then check which columns that Index object contains.
Those will be all of the columns of the primary key, even if it's a
composite primary key.

thank you very much.
When using VB .Net, it generally takes three to five times longer to program
the equivalent built-in Access features and VBA capabilities. If you're
programming an Access database, then the recommended method is to use
Access, because Access's RAD environment so much quicker and cheaper to
develop with when an experienced developer is using it.

The project i'm working on is a quite complicated one....
and even tho i know i'll be working with an access database, i can't
know for sure if the person i'm programming for even has access.
but i'm far from an experienced developer in windows environments.
 
R

RoyVidar

xyious said:
i need to do the above....

i need to figure out which column has the primary key, if any, in the
current table, or all tables.... any way to find out would be good...

You'd probably get more relevant assistance in a NG related to VB.Net,
but check out the GetOleDbSchemaTable method.

Here's a MS KB article http://support.microsoft.com/kb/309488/en-us

Primary keys are the last sample. Just modify the connection string
so that it connects to Jet in stead of SQL Server, see for instance
http://www.connectionstrings.com/?carrier=access
 
Top