PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
HOW TO: Determine if Access column is an AutoNumber
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
HOW TO: Determine if Access column is an AutoNumber
![]() |
HOW TO: Determine if Access column is an AutoNumber |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
In ADO.Net, how might one determine whether a column in an Access table is an
AutoNumber type? Could this be accomplished using OleDbSchemaGuid. If so could you give an example. Thanks for the tip. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Burton G. Wilkins wrote:
> In ADO.Net, how might one determine whether a column in an Access table is an > AutoNumber type? > > Could this be accomplished using OleDbSchemaGuid. If so could you give an > example. No, use this trick: OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [" + tableName + "] WHERE 1=0", openConnection); DataTable tableSchema = adapter.FillSchema(new DataTable(), SchemaType.Source); for (int j = 0; j < tableSchema.Columns.Count; j++) { if(tableSchema.Columns[j].AutoIncrement) { // is identity } } Frans -- ------------------------------------------------------------------------ Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma Microsoft MVP (C#) ------------------------------------------------------------------------ |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Thank you, Frans. You have provided a good trick indeed.
"Frans Bouma [C# MVP]" wrote: > Burton G. Wilkins wrote: > > In ADO.Net, how might one determine whether a column in an Access table is an > > AutoNumber type? > > > > Could this be accomplished using OleDbSchemaGuid. If so could you give an > > example. > > No, use this trick: > OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [" + > tableName + "] WHERE 1=0", openConnection); > > DataTable tableSchema = adapter.FillSchema(new DataTable(), > SchemaType.Source); > > for (int j = 0; j < tableSchema.Columns.Count; j++) > { > if(tableSchema.Columns[j].AutoIncrement) > { > // is identity > } > } > > Frans > > -- > ------------------------------------------------------------------------ > Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com > My .NET blog: http://weblogs.asp.net/fbouma > Microsoft MVP (C#) > ------------------------------------------------------------------------ > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

