[BUG] OleDb driver for .NET doesn't report ordinals for PK fields correctly

  • Thread starter Thread starter Frans Bouma
  • Start date Start date
F

Frans Bouma

When you use the GetOleDbSchemaTable() method of the OleDb connection object
with the parameter OleDbSchemaGuid.Primary_Keys and you request the primary
key fields for a table which has the primary key fields at ordinal positions
other than the first fields (for example column 3 is the primary key field),
the GetOleDbSchemaTable() method will return a set of PK fields in a
datatable but the column 'ORDINAL' in that datatable doesn't contain the
right ordinals: it always contains values which start with '1' and count up.

The ORDINAL column is therefore not usable, it doesn't reflect the correct
value. Please fix. :)

TIA

Frans Bouma
http://www.llblgen.com
 
¤ When you use the GetOleDbSchemaTable() method of the OleDb connection object
¤ with the parameter OleDbSchemaGuid.Primary_Keys and you request the primary
¤ key fields for a table which has the primary key fields at ordinal positions
¤ other than the first fields (for example column 3 is the primary key field),
¤ the GetOleDbSchemaTable() method will return a set of PK fields in a
¤ datatable but the column 'ORDINAL' in that datatable doesn't contain the
¤ right ordinals: it always contains values which start with '1' and count up.
¤
¤ The ORDINAL column is therefore not usable, it doesn't reflect the correct
¤ value. Please fix. :)
¤

What kind of database (and OLEDB provider) are you using?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
¤ When you use the GetOleDbSchemaTable() method of the OleDb connection
object ¤ with the parameter OleDbSchemaGuid.Primary_Keys and you request
the primary ¤ key fields for a table which has the primary key fields at
ordinal positions ¤ other than the first fields (for example column 3 is
the primary key field), ¤ the GetOleDbSchemaTable() method will return a
set of PK fields in a ¤ datatable but the column 'ORDINAL' in that
datatable doesn't contain the ¤ right ordinals: it always contains
values which start with '1' and count up. ¤
¤ The ORDINAL column is therefore not usable, it doesn't reflect the
correct ¤ value. Please fix. :)
¤

What kind of database (and OLEDB provider) are you using?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)

SqlServer, the SQLOLEDB driver is specified in the connection
string. Sorry, I should have mentioned that in the posting.

FB
 
¤ ¤
¤ > On Sun, 14 Sep 2003 04:06:06 -0700, Frans Bouma <[email protected]>
¤ > wrote:
¤ >
¤ > ¤ When you use the GetOleDbSchemaTable() method of the OleDb connection
¤ > object ¤ with the parameter OleDbSchemaGuid.Primary_Keys and you request
¤ > the primary ¤ key fields for a table which has the primary key fields at
¤ > ordinal positions ¤ other than the first fields (for example column 3 is
¤ > the primary key field), ¤ the GetOleDbSchemaTable() method will return a
¤ > set of PK fields in a ¤ datatable but the column 'ORDINAL' in that
¤ > datatable doesn't contain the ¤ right ordinals: it always contains
¤ > values which start with '1' and count up. ¤
¤ > ¤ The ORDINAL column is therefore not usable, it doesn't reflect the
¤ > correct ¤ value. Please fix. :)
¤ > ¤
¤ >
¤ > What kind of database (and OLEDB provider) are you using?
¤ >
¤ >
¤ > Paul ~~~ (e-mail address removed)
¤ > Microsoft MVP (Visual Basic)
¤
¤ SqlServer, the SQLOLEDB driver is specified in the connection
¤ string. Sorry, I should have mentioned that in the posting.
¤

I'm thinking that the ordinal represents the position of the column with respect to the Primary Key
Columns collection (or Index) and not the position in the Table (or View) Columns collection.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
¤ ¤
¤ > On Sun, 14 Sep 2003 04:06:06 -0700, Frans Bouma
¤ >
¤ > ¤ When you use the GetOleDbSchemaTable() method of the OleDb
connection ¤ > object ¤ with the parameter OleDbSchemaGuid.Primary_Keys
and you request ¤ > the primary ¤ key fields for a table which has the
primary key fields at ¤ > ordinal positions ¤ other than the first
fields (for example column 3 is ¤ > the primary key field), ¤ the
GetOleDbSchemaTable() method will return a ¤ > set of PK fields in a ¤
datatable but the column 'ORDINAL' in that ¤ > datatable doesn't contain
the ¤ right ordinals: it always contains ¤ > values which start with '1'
and count up. ¤ ¤ > ¤ The ORDINAL column is therefore not usable, it
doesn't reflect the ¤ > correct ¤ value. Please fix. :)
¤ > ¤
¤ >
¤ > What kind of database (and OLEDB provider) are you using?
¤ >
¤ >
¤ > Paul ~~~ (e-mail address removed)
¤ > Microsoft MVP (Visual Basic)
¤
¤ SqlServer, the SQLOLEDB driver is specified in the connection
¤ string. Sorry, I should have mentioned that in the posting.
¤

I'm thinking that the ordinal represents the position of the column with
respect to the Primary Key Columns collection (or Index) and not the
position in the Table (or View) Columns collection.

How can that be of any use? The ordinal can be used to find the PK
field in the field collection of a table, so you don't have to use string
compares. Now, with this ordinal values you can't do that :) (you can, but
only if hte PK is made up by the first field(s) in a table ;)). I couldn't
find information about what the ordinal column would represent, but how it
is used now is definitely not useful, so I think it is OR a bug, OR it
should be changed that is IS useful :)

FB
 
¤ ¤
¤ > On Mon, 15 Sep 2003 10:08:16 -0700, Frans Bouma <[email protected]>
¤ > wrote:
¤ >
¤ > ¤ ¤ > ¤
¤ > ¤ > On Sun, 14 Sep 2003 04:06:06 -0700, Frans Bouma
¤ > ¤ >
¤ > ¤ > ¤ When you use the GetOleDbSchemaTable() method of the OleDb
¤ > connection ¤ > object ¤ with the parameter OleDbSchemaGuid.Primary_Keys
¤ > and you request ¤ > the primary ¤ key fields for a table which has the
¤ > primary key fields at ¤ > ordinal positions ¤ other than the first
¤ > fields (for example column 3 is ¤ > the primary key field), ¤ the
¤ > GetOleDbSchemaTable() method will return a ¤ > set of PK fields in a ¤
¤ > datatable but the column 'ORDINAL' in that ¤ > datatable doesn't contain
¤ > the ¤ right ordinals: it always contains ¤ > values which start with '1'
¤ > and count up. ¤ ¤ > ¤ The ORDINAL column is therefore not usable, it
¤ > doesn't reflect the ¤ > correct ¤ value. Please fix. :)
¤ > ¤ > ¤
¤ > ¤ >
¤ > ¤ > What kind of database (and OLEDB provider) are you using?
¤ > ¤ >
¤ > ¤ >
¤ > ¤ > Paul ~~~ (e-mail address removed)
¤ > ¤ > Microsoft MVP (Visual Basic)
¤ > ¤
¤ > ¤ SqlServer, the SQLOLEDB driver is specified in the connection
¤ > ¤ string. Sorry, I should have mentioned that in the posting.
¤ > ¤
¤ >
¤ > I'm thinking that the ordinal represents the position of the column with
¤ > respect to the Primary Key Columns collection (or Index) and not the
¤ > position in the Table (or View) Columns collection.
¤
¤ How can that be of any use? The ordinal can be used to find the PK
¤ field in the field collection of a table, so you don't have to use string
¤ compares. Now, with this ordinal values you can't do that :) (you can, but
¤ only if hte PK is made up by the first field(s) in a table ;)). I couldn't
¤ find information about what the ordinal column would represent, but how it
¤ is used now is definitely not useful, so I think it is OR a bug, OR it
¤ should be changed that is IS useful :)
¤
¤ FB


Is there a reason why you can't use the column name instead of the column ordinal?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Is there a reason why you can't use the column name instead of the
column ordinal?

I now use the column name to work around this, but ordinals are
faster, since these can be used as indices. :)

FB
 
¤ ¤
¤ > Is there a reason why you can't use the column name instead of the
¤ > column ordinal?
¤
¤ I now use the column name to work around this, but ordinals are
¤ faster, since these can be used as indices. :)
¤

Yes, that is true. I will see if I can dig up some more info on this.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top