Solved

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

Posted on 1998-10-09
8
174 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 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