We help IT Professionals succeed at work.

Display Database table names in a combo box, using ADO objects

nazar66
nazar66 asked
on
Medium Priority
194 Views
Last Modified: 2013-12-25
I am trying to add the names of tables located in a database to a combo box on my form. I need to use ADO objects. Any one can help?
I am using VB5 (Prof. & Enterprise version)

Comment
Watch Question

Commented:
What is the back-end database?

Commented:
  Dim nI   As Integer
   
   For nI = 1 To DB.TableDefs.Count
      cbCombo.Add DB.TableDefs(nI).Name
   Next

Author

Commented:
Waty,

I don't have the object DB in ADODB (ADO).
I can't see any methods or objects named TableDef in ADODB.

I know that the stored procedure sp_tables will return the tables in a database but I couldn't execute this proceture using ADO objects.


mcix,

The database is SQL Server (OLE DB) using the ADO objects.




Regards,

Commented:
Did you get an error message or no results?

Commented:
the solution was for DAO, so reject my answer.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
   Dim nI As Integer
    For nI = 0 To Workspaces(0).Databases(0).TableDefs.Count - 1
        Combo1.AddItem Workspaces(0).Databases(0).TableDefs(nI).Name
    Next

Author

Commented:
thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.