Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Add Database Names, table names & related fields from table in combo box

Hello All.

I have three combo box on my vb form namely.
1. cmbDatabases.
2. cmbTables.
3. cmbFields.

I have connected to mysql through ADODB.
Their are above 100 databases in mysql.
What i want is to show these databases names in 1st combo box i.e.
cmbDatabases then
show table names from selected database in 2nd combo box i.e. cmbTables
and then show related fields from tables in 3rd combo box i.e
cmbfields.

can anyone tell me how to fetch databases name, related tables & fields
in combo box.

Thanks
Snowy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Add Database Names, table names & related fields from table in com

To get the list of tables, you need to be connected to a database, to get the
list of fields, you need a reference to a table. I am not sure how you will
get a list of databases without a connection; to get a connection you need a
specific database.

If you were using SQL Server, you could use the SQLDMO object; but that does
not work with other databases.

Assuming you have a connection to a database, you can get a list of tables
(and their types) and for each table the fields and their types using the
ADOX.Catalog object.

Set xx=CreateObject("ADOX.Catalog")
xx.ActiveConnection = {whatever that is for mysql}
for each table in xx.Tables
debug.print table.Name
for each fld in table.Fields
debug.print fld.name ' fld.Type
next
next


"Snowy" wrote:

Hello All.

I have three combo box on my vb form namely.
1. cmbDatabases.
2. cmbTables.
3. cmbFields.

I have connected to mysql through ADODB.
Their are above 100 databases in mysql.
What i want is to show these databases names in 1st combo box i.e.
cmbDatabases then
show table names from selected database in 2nd combo box i.e. cmbTables
and then show related fields from tables in 3rd combo box i.e
cmbfields.

can anyone tell me how to fetch databases name, related tables & fields
in combo box.

Thanks
Snowy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Add Database Names, table names & related fields from table in com

In ODBC Data Sources Administrator I have configer the DSN name &
through that connect to database. Then I have following code to create
database connection.

Public fileconn As New ADODB.Connection

Public Sub CreateConnections()
fileconn.Open "DSN=<DSN Name"
End Sub

With this code I'm able to connect to databases.
But what I want; I should able to display database name in combo box.
Their are 100 databases. I want to add all these 100 databases name in
combo box.
After selecting 1 database name among 100 databases from combo box,
Second combo box display the tables from selected databases and 3rd
combo box display fields from that table.
For e.g when you create(Configure) System DSN through Administrative
Tool, Data Source (ODBC). Their are Database selection list. I just
want such list in my VB program.

Please help me

Thanks
Snowy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Add Database Names, table names & related fields from table in


fileconn.Open "DSN=<DSN Name"

If your statement above is successsful, the DSN has the name of the database
embedded within it, does it not? You are connecting to the database.

In order to enumerate the databases in the Server, you will need to connect
to the serveritself ... there must be a low level ODBC API for this (of which
I have no experience). If you have ODBC help on your PC, look therein. Or
Google.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Add Database Names, table names & related fields from table in

Yes, after all, you can enumerate the database names!! HEre's how:

Sub ss()
cn='your connection string
set xx = CreateObject("ADODB.Connection")
xx.Open cn
set xy = xx.OpenSchema(1) ' Catalogs
debug.print xy.GetString ' prints the names of the databases, delimited
by vbCRLF

End Sub

The xy object has a number of methods; use the GetRows method (with the
appropriate argument) to get 1 row at a time and add it to your COMBO.
You might want to use Early Binding: then Intellisense will give you all
the clues you need.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parameterisation of table names Tom O''Riordan Excel Worksheet Functions 2 March 1st 10 10:57 AM
fields names do not show in excel 2007 pivot table fields list marlo17 New Users to Excel 2 December 1st 08 01:25 PM
Using names, and related information, in a Pivot Table? RyGuy Excel Worksheet Functions 2 January 1st 08 01:50 AM
Combo box to link to SQL Database table in Excel 2007 Seok Bee Excel Discussion (Misc queries) 0 August 6th 07 08:20 AM
repeating names in row fields of a pivot table Jack N Excel Discussion (Misc queries) 1 August 18th 06 04:37 PM


All times are GMT +1. The time now is 01:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"