[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Getting Foreign Key information of an ADO.Recordset Field

Posted on 2004-10-27
Medium Priority
Last Modified: 2013-12-25

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 ;)
Question by:osullil
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 29

Accepted Solution

leonstryker earned 1000 total points
ID: 12422658
You have two options here.  The first option is to add a column to your table which will identify if the column is part of a foreign key, or you may run the sp_fkeys system store procedure in order to retrieve this information:



Author Comment

ID: 12424588
The second option is the best as I want to remove as much of the meta data information to try and minimise the margin of error when configuring.  I had hoped though that there would be some way to get information through ADO recordset to avoid having to send another query to database.
LVL 29

Expert Comment

ID: 12424680
>>I had hoped though that there would be some way to get information through ADO recordset to avoid having to send another query to database.

You should create a store procedure which does this for you.  That way you would still need to make only one call the server.


Author Comment

ID: 12432392
Stored procedure would be a little tricky seeing as the query to retrieve data is programmatically generated based on meta data table which stores table and column names used by the dynamic controls.  I will add the sp_fkeys call as part of this batch though so still only one call to server and use the rs.Nextrecordset to get to foreign keys recordset.

Thanks for the help on this

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question