Getting Foreign Key information of an ADO.Recordset Field
Posted on 2004-10-27
I am writing a VB6 application that is designed to be generic so a lot of meta-data is stored in SQL Server 2000 database, with controls being dynamically added to forms based on database settings.
Currently in my metadata table I have a column called DataListSQL which is used to store the SQL required to populate the combobox control, and have another field to say what type of control it is (Combobox, Textbox, Checkbox, Label).
I want to miminise the amount of work required for the administration so I was hoping to programmatically determine the type of control to be displayed based on the field data type. The problem is I don't know how to determine from the Adodb.recordset if a field is a foreign key and so should be a combobox. If it is a foreign key column I would like to know the foreign key table and column name so I can select all the values from this table to populate the combobox control.
I hope this makes sense to people outside my head ;)