Solved

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

Posted on 1998-10-09
8
176 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)

0
Comment
Question by:nazar66
[X]
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
  • 2
  • +2
8 Comments
 
LVL 4

Expert Comment

by:mcix
ID: 1496804
What is the back-end database?
0
 
LVL 14

Expert Comment

by:waty
ID: 1496805
  Dim nI   As Integer
   
   For nI = 1 To DB.TableDefs.Count
      cbCombo.Add DB.TableDefs(nI).Name
   Next

0
 

Author Comment

by:nazar66
ID: 1496806
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:mcix
ID: 1496807
Did you get an error message or no results?
0
 
LVL 14

Expert Comment

by:waty
ID: 1496808
the solution was for DAO, so reject my answer.
0
 
LVL 2

Accepted Solution

by:
Veroland earned 100 total points
ID: 1496809
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
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1496810
   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
 

Author Comment

by:nazar66
ID: 1496811
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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