Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: Bug w/ OleDbDataReader.GetSchemaTable()???


Message #1 by "Sean McCormack" <sean@a...> on Tue, 18 Mar 2003 14:50:50
I'm developing an application that loads schema information. Since it's 
not known before hand what database will be accessed, I'm using the 
OleDbDataReader.GetSchemaTable(), vs. using data base specific libraries 
(i.e. SqlDataReader, etc.). 

Currently I'm testing it against Sql Server's Northwind database. This is 
the output I get for the SupplierId column in the Suppliers table: 

ColumnName = SupplierID 
ColumnOrdinal = 0 
ColumnSize = 4 
NumericPrecision = 10 
NumericScale = 255 
DataType = System.Int32 
ProviderType = 3 
IsLong = False 
AllowDBNull = False 
IsReadOnly = True 
IsRowVersion = False 
IsUnique = False 
IsKey = False 
IsAutoIncrement = False 
BaseSchemaName = 
BaseCatalogName = 
BaseTableName = 
BaseColumnName = 

Most important are these three properties: 

IsUnique = False 
IsKey = False 
IsAutoIncrement = False 

You'll note that it is not being viewed as unique, a key, or 
autoincrement -- but the SupplierId column is all three?!? The rest of the 
properties are being properly assigned. 

The code that I'm using is straight from Microsoft's HOW-To section: 
http://support.microsoft.com/default.aspx?scid=kb;en-us;310107 

It simply iterates through the resultant DataTable, and reads the schema 
column name and property. 


Likewise, I ran it against an Access database. I have a table name 
Category with a CategoryId column as the primary key, autonumber. Here is 
the output: 

ColumnName = CategoryID 
ColumnOrdinal = 0 
ColumnSize = 4 
NumericPrecision = 10 
NumericScale = 255 
DataType = System.Int32 
ProviderType = 3 
IsLong = False 
AllowDBNull = False 
IsReadOnly = True 
IsRowVersion = False 
IsUnique = False 
IsKey = False 
IsAutoIncrement = False 
BaseSchemaName = 
BaseCatalogName = 
BaseTableName = 
BaseColumnName = 

Once again, these properties are not appearing correctly: 

IsUnique = False 
IsKey = False 
IsAutoIncrement = False 


This appears to be a bug w/ the OleDb namespace. Does anyone know: 

1. If I'm doing something wrong? 
2. If this is a bug, has it been fixed? I have the .NET SP2, which didn't 
do anything. 
3. Is there a workaround? How else can I programmatically find out if a 
column is an identity/autonumber column or not? 
4. If this is a bug, how can I get notify MS of it? 

Please advise. Thanks! 

Sean

  Return to Index