Re: Determining Foreign/Primary Keys in a Table

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello Jason,
"Jason D." <Tronman@xxxxxxxxx> wrote:

JD> Hello, I'm looking for a generic way to determine Foreign/Primary
JD> keys for a table in a Database I'm connected to via ODBC. The two
JD> examples I've been working with so far are an Access Database and
JD> an Oracle Database.
JD>
JD> What I've tried so far:
JD>
JD> I can determine Primary Keys (using the System.Data.ODBC controls
JD> in .NET) but not foreign keys.
JD>
JD> Also, I've been trying to use the API-calls SQLPrimaryKeys and
JD> SQLForeignKeys from Visual C++ 6.
JD>
JD> SQLForeignKeys doesn't crash, but doesn't return anything.
JD> SQLPrimaryKeys works properly in Oracle; but Access gives me an
JD> error number of -1 (Driver does not support this function). How
JD> could it not support this? Any why won't ForeignKeys return
JD> anything at all (I have specifically set and committed the foreign
JD> keys).

For the Access driver, you can simulate SQLForeignKeys() by means of
selecting from MSysRelationships table and SQLPrimaryKeys() by means of
SQLSpecialColumns().

For sample code in Lisp, you could take a look at the access-odbc.lisp
source file in the library mentioned below.
--
Sincerely,
Dmitriy Ivanov
Common Lisp ODBC interface - lisp.ystok.ru/ysql.html


.



Relevant Pages

  • Re: Reading and updating an Sql Server 2005 database from Access 2007
    ... server 2005 database to view and update data in the sql tables. ... The problem is that I have foreign keys (and therefore ...
    (microsoft.public.access.adp.sqlserver)
  • Re: ER Diagraming tool
    ... ODBC to connect to your database so it will work with any database with ... I am looking for an ER diagram tool to help me document a database ... keys in the ER diagram so that I do not have to manually create all of ...
    (borland.public.delphi.non-technical)
  • Re: Key attributes with list values was Re: What are the differences ...KEY
    ... Jane Harper is married. ... And a constraint that states that single people cannot become divorced. ... database, or users, for that matter, to distinguish between them. ... That's the whole point of keys. ...
    (comp.databases.theory)
  • Re: Pin generation algorithm question
    ... the keys would be a big ... Suppose that we have a database that contains all valid numbers, ... load among several servers that all need access to this database. ... So the only real problem is which systems are accessing this crypto box. ...
    (sci.crypt)
  • Re: Database design, Keys and some other things
    ... >> Or 'the database has no opinion as what Donald Trump's e-mail address might ... some keys can be wrong or a data can ... Meaning is not related to just one number. ... > is concerned a VIN is not a surrogate key, ...
    (comp.databases.theory)