13

C # / Access Getting primary keys from Access 2003

 3 years ago
source link: https://www.codesd.com/item/c-access-getting-primary-keys-from-access-2003.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

C # / Access Getting primary keys from Access 2003

advertisements

I'm using OleDb to interact with an Access database, and I'm trying to find out how to get the primary keys of each table, but in such a way that they are associated with the tables. In other words, I don't just want a flat list of the primary key column names--I want to be able to determine which table they belong to.

Any idea how to do this? I've used the GetSchema() method to get a table of tables, but that table's information does not appear to include primary keys (or any other indexes, for that matter).


Ok--did a little outputting of column names and got a better understanding of how the schema tables are related.

To do this, pass the string "Indexes" to the GetSchema() method. Each record in the index table contains both the table name and whether or not the index is the primary key.

Related Articles

How to get PRIMARY KEY from the database using the value of another column? (Android, SQLite)

I've got a table with id INTEGER PRIMARY KEY AUTOINCREMENT column and NAME VARCHAR column. And I know the value of the NAME column. How do I retrieve id of the row that contains the value?my SQLite is rusty, but something along these lines should wor

Extract the primary key from an entity object in JPA 2.0?

Let's say we have an entity object. Is there a way to extract a primary key from it? I want to do something like this: public static Object extractPrimaryKey(EntityManager em, Object obj) { return em.giveMeThePrimaryKeyOfThisEntityObject(obj); } Reas

Primary key composed of primary keys from other tables

I am working on an assignment and I'm a little rusty with my SQL basics as I mainly work with already created tables, not with creating them. I was given a database model and asked to create it. I was told the model may have errors and to just correc

pyodbc - Read primary keys from MS Access database (MDB)

When I try to use cursor.primaryKeys("tablename") then exception occurs: Error: ('IM001', '[IM001] [Microsoft][ODBC Driver Manager] Driver does not support this function (0) (SQLPrimaryKeys)') list(cursor.columns(table='tablename')) does not rev

How to get a single primary key from a range, select in simultaneous table reads

Morning, I've got multiple clients trying to get a unique primary key on a table. A row identified by that PK is considered "valid" only if they match a successful range scan. The range scan is SELECT id FROM lookup WHERE allowed='Y' and updated

jqGrid - How to add a row to a subgrid? or how to get the primary key from the parent line?

I am using ASP.MVC and jqgrid 3.7.2. The data loads OK into the grid and subgrid. Updating the master part of the table works great. I can update or remove a row from the subgrid since one of the fields in the subgrid is the primary key of the parent

Getting the Autonumber Primary Key from MS SQL Server

I am currently working in C#, and I need to insert a new record into one table, get the new primary key value, and then use that as a foreign key reference in inserting several more records. The Database is MS SQL Server 2003. All help is appreciated

Inserting many lines in EF too slow, how to get the primary key from SqlBulkCopy?

We have a use case in our application where a user triggers a request that will cause an insert of 100 to 1000 rows. After that insert, we need the object to continue processing and create more objects which are foreign keys to the originally inserte

get a primary key from the table

With php, I am trying to retrieve a primary key so i can insert it into another table as i am trying to connect the two table so I can use them later. I am retrieving a garbage value when print it and when I insert it into usermeet table it insert 0

Changing primary keys from multiple rows at a time

I have a table titled KEYS that looks like the following. The id and version columns are both primary keys. || id* | version* | value || -------------------------------- || 1 | 1 | "asdf" || || 1 | 2 | "jkl;" || || 1 | 3 | "qwerty

Change the Auto-Increment field, Primary Key from SMALLINT to INT in SQL Server

What is the best way (low impact/low risk) to change a primary key field from SMALLINT to INT? The field is configured to use "Identity Increment" to auto-increment. I'm starting with the following SQL: ALTER TABLE category_types ALTER COLUMN id

Generic Entity Framework method to retrieve the primary key from combobox

I have very simple issue: I have a custom control that is based on a combobox. Each instance of it has a list of database entities as Datasource (such as "Orders", "Items", "Customers" etc). I need a generic approach, that si

Designing the Database: Primary Key from Multiple Data Sources

Initially I was importing foods from an excel document from Food Source 1 and it had VARCHAR type primary*(PK example #FOOD0001)* (Because there was only 1 source at the time I just imported directly into the foods table with auto incrementing int ID

Copy a primary key from a target table as a foreign key to the source table on an insert

This question already has an answer here: Using merge..output to get mapping between source.id and target.id 2 answers The Situation: I am inserting information from one table to another, a source and target. When the information is inserted into the

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK