I was wondering if there was a way to get the unique/primary/foreign keys via SDAC components. I would like to be able to know what field contains one of these.
Also, is there a way to retrieve the default value for a field?
Getting Key & Default Values
You can learn if the field is key using the TFieldDesc.IsKey property. To get the TOLEDBFieldDesc object of the field you should use the following code:
In order to know the default value of a field you should set the TMSQuery.Options.DefaultValues property to True before opening a dataset and after opening it you can use the TFields.DefaultExpression property that holds the default value.
Also you can use the TMSMetadata component to obtain metainformation about database objects from the server, including information about primary key.
Code: Select all
MSQuery.GetFieldDesc('FieldName') as TOLEDBFieldDesc
Also you can use the TMSMetadata component to obtain metainformation about database objects from the server, including information about primary key.