PDA

Click to See Complete Forum and Search --> : ADO - Listing Tables and Fields


omarswan
Apr 7th, 2000, 04:37 AM
Hi,
I have two questions:
(1) How do you load/ist all the Tables from a Database into a combo box or a list box ??

(2) How do load/list all the Fields from a Table into a combo box or a list box ??


:) Thanks :)

anandkumar
Apr 8th, 2000, 01:29 PM
Hi,
Collecting all tables and putting in to a listbox
*************************************************

very good question, i will idea to get the tables
from ORACLE, you try it.

1. Create a ADODB instance
(Project -> Reference
Microsoft ActiveX Data Objects )
2. dim conn as new adodb.connection
dim res as new adodb.recordset

3. Establish a connection through connectionstring

4. open a recordset by using sql statement using
a data dictionary USER_TAB_COLUMNS

5. create a listbox
6. for i = 0 to recordset object.recordcount-1
listbox1.additem recordset object(i)
next i

try this , surely this will work,
bye,
reply soon, my addresss anand143_99@yahoo.com (anand)

Clunietp
Apr 9th, 2000, 09:22 AM
List all tables:

'references:
'ActiveX Data Objects 2.x
'ADO 2.x for DDL and security

Dim tbl As ADOX.Table
Dim cn As ADODB.Connection

Dim ax As ADOX.Catalog

Set cn = New ADODB.Connection

'connect
cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=Nwind.mdb"

Set ax = New ADOX.Catalog

ax.ActiveConnection = cn

'loop thru tables
For Each tbl In ax.Tables
Debug.Print tbl.Name & " " & tbl.Type
Next tbl

'close connection
cn.Close
Set cn = Nothing


List all fields in a table:

'uses ADO 2.5
' ADO 2.5 for DDL and security

Dim cn As Connection
Dim ax As Catalog
Dim tbl As Table
Dim fld As Field
Dim cl As Column
Set cn = New Connection

'open connection to db
cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=NWind.mdb"

Set ax = New Catalog
ax.ActiveConnection = cn

'get table reference
Set tbl = ax.Tables("Employees")

'list all fields
For Each cl In tbl.Columns
Debug.Print cl.Name
Next cl

'cleanup
Set cl = Nothing
Set ax = Nothing

cn.Close
Set cn = Nothing

anandkumar
Apr 9th, 2000, 10:02 AM
THANKS FOR REPLYING, YOU DID'NT MENTIONED ABOUT ORACLE
TABLE,

HOW TO DOWNLOAD A FILE FROM THE WEB SERVER (THROUGH
VB CODING).