Board index » delphi » Primary Key Field Attribute

Primary Key Field Attribute

In Delphi 6E ADO, how do I examine a field and know if it is a Primary Key
field ? Currently, I know the data type of each field but there is no method
within the FieldDef to specify if the field is a primary key.

TIA

DM

 

Re:Primary Key Field Attribute


Quote
> In Delphi 6E ADO, how do I examine a field and know if it is a Primary Key
> field ?

You could check the field.properties collection after the recordset is
opened (assuming your oledb provider supports this property).

{From memory}
AdoDataset1.Recordset.Fields[x].Properties('keycolumn').value

You can view such properties in adoanywhere browser, I just checked and this
property works for Access using Jet. Trial From
http://www.adoanywhere.com/download/aaBrowser.zip

(You could also use connection objects openschema procedure to extract
database design information. There is a useful openschema gui built into the
same browser)

--
Mike Collier BSc (Hons)
www.adoanywhere.com
ADO Interactive Object Browser Tool
Trial From http://www.adoanywhere.com/download/aaBrowser.zip

Quote
"DM" <DataMana...@Yahoo.Com> wrote in message

news:3d7f5c12@newsgroups.borland.com...
Quote
> In Delphi 6E ADO, how do I examine a field and know if it is a Primary Key
> field ? Currently, I know the data type of each field but there is no
method
> within the FieldDef to specify if the field is a primary key.

> TIA

> DM

Re:Primary Key Field Attribute


Quote
>In Delphi 6E ADO, how do I examine a field and know if it is a Primary Key
>field ? Currently, I know the data type of each field but there is no method
>within the FieldDef to specify if the field is a primary key.

If your Oledb provider supports it you can use openSchema like this to get
keyfields

ADOConnection1.OpenSchema(siPrimaryKeys
,VarArrayOf([Null,Null,'TableNameYouAretryingTogetkeyof']),EmptyParam,ADODataSet1)

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Primary Key Field Attribute


Thanks Brian. The OpenSchema wporks very well.

DM

"Brian Bushay TeamB" <BBus...@Nmpls.com>

Quote
> ADOConnection1.OpenSchema(siPrimaryKeys

,VarArrayOf([Null,Null,'TableNameYouAretryingTogetkeyof']),EmptyParam,ADODat
aSet1)
Quote

Other Threads