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

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)

nazar66Asked:
Who is Participating?
 
VerolandConnect With a Mentor Commented:
Use the following SQL statement , It worked for me:
"select name from sysobjects where type = 'U' order by name"

This brings the names of all the tables in the connected database
0
 
mcixCommented:
What is the back-end database?
0
 
watyCommented:
  Dim nI   As Integer
   
   For nI = 1 To DB.TableDefs.Count
      cbCombo.Add DB.TableDefs(nI).Name
   Next

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
nazar66Author 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,

0
 
mcixCommented:
Did you get an error message or no results?
0
 
watyCommented:
the solution was for DAO, so reject my answer.
0
 
MirkwoodCommented:
   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
0
 
nazar66Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.