Re: How to determine if a table has a column that is autoincrement(Identity)?
From: Paul Clement (UseAdddressAtEndofMessage_at_swspectrum.com)
Date: 06/03/04
- Next message: John: "Does access support "CREATE PROCEDURE"?"
- Previous message: James: "Re: DataTable.LoadDataRow Purgutory"
- In reply to: Joe: "How to determine if a table has a column that is autoincrement(Identity)?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 03 Jun 2004 09:48:06 -0500
On 2 Jun 2004 20:22:11 -0700, anon03@comcast.net (Joe) wrote:
¤ Hi All,
¤
¤ I am trying to find out how to determine if a table that I am
¤ working with contains a column that is an identity column (ie,
¤ has autoincrement set to true). I am working in C# and I'm
¤ already using the GetOleDbSchemaTable method to get the schema
¤ for the table I am interested in. However, this DataTable that
¤ I get back does give me the names of the columns but it does
¤ not tell me if a column is an identity column, or at the very
¤ least I don't know where to look for it in the Datatable. This
¤ is the call I am using:
¤
¤ DataTable dtCols = conn.GetOleDbSchemaTable(
¤ OleDbSchemaGuid.Columns,
¤ new Object[]{null, null, sTableName, null});
¤
¤ Now I've seen posts and visted websites that say you can get
¤ the autoincrement/identity flag by accessing the Columns data
¤ member as such:
¤
¤ dtCols.Columns[i].AutoIncrement
¤
¤ Now, although this flag is there, it seems to be associated
¤ with some meta-data column. In fact, all of the Columns that
¤ are in the DataTable(dtCols, the table that I get from the
¤ call above) seem to be associated with the table's meta-data
¤ (like, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME). Its the Rows
¤ data member that contains information on the columns of the
¤ table but I can't find any reference to the autoincrement or
¤ identity flag. I was hoping it would be in this DataTable
¤ since I could make one function call and get all I need.
¤
¤ Can someone please tell me how I can programatically get this
¤ flag or tell me where to find it? Thanks in advance.
An auto increment column is implemented differently depending upon the type of database you are
working with. It isn't exposed via GetOleDbSchema.
As Miha mentioned, we would have to know what the database product is that you are using.
Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)
- Next message: John: "Does access support "CREATE PROCEDURE"?"
- Previous message: James: "Re: DataTable.LoadDataRow Purgutory"
- In reply to: Joe: "How to determine if a table has a column that is autoincrement(Identity)?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|