Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2005, 06:56 AM
Authorized User
 
Join Date: Jan 2005
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I get a list of all tables of Oracle DB?

How do I get a list of all tables of Oracle DB?


Following is the code in which i have marked the point (in comments) where I need assistance

Sub OracleToExcel()

Dim conn As New ADODB.Connection
conn.Open "driver={Microsoft ODBC for Oracle};" & _
    "server=js;" & _
    "uid=hsonsche;pwd=hsons"


'here I need an array to contain names of all tables in the database
'The array is to be listed on the sheet1 of active workbook first.
'Then following part of the VBA is to be executed for all tables in the array one-by-one


Dim rs As New Recordset
Tabname = "supplier"
rs.Open "Select * From " & Tabname, conn, adOpenStatic, adLockReadOnly, adCmdText
Workbooks.Add
ActiveCell = "Table Name " & Tabname
ActiveCell.Offset(1, 0).Select
x = 1
For k = 0 To rs.Fields.Count - 1
    ActiveCell.Offset(0, k) = rs(k).Name

Next
ActiveCell.Offset(1, 0).Select
ActiveWindow.FreezePanes = True
MsgBox (rs.RecordCount & vbCr & "records")
    Do While Not rs.EOF

        For k = 0 To rs.Fields.Count - 1
            ActiveCell.Offset(0, k) = rs(k).Value

        Next
        ActiveCell.Offset(1, 0).Select
        rs.MoveNext
        'rs.MoveFirst
    Loop

    'Close the recordset
    rs.Close


conn.Close
End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pull excel data into oracle tables yogeshyl Oracle 1 January 9th, 2008 12:38 PM
Oracle Nested Tables prabodh_mishra Pro VB Databases 1 April 26th, 2006 12:15 PM
Getting list of tables using DB name shazia1 VS.NET 2002/2003 2 July 6th, 2005 12:17 PM
how to get backup from oracle db umair_rathore Oracle 2 July 6th, 2005 01:25 AM
Error When linking Oracle Tables to Access mtullock Access 2 January 16th, 2004 10:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.