Results 1 to 3 of 3

Thread: *Resolved* How to retrieve access table and column information

  1. #1

    Thread Starter
    Lively Member Flustor's Avatar
    Join Date
    Sep 2001
    Location
    A small hole in Birmingham
    Posts
    76

    *Resolved* How to retrieve access table and column information

    Hi

    I need to upload Access tables to Oracle and I was wondering if anyone had a better way of doing it than the way I'm thinking...

    I'm going to write a VB app to read the column headings from Access and create the script for Oracle. My two problems are:

    a) Determining the datatype of a column in Access
    b) Reading table names from Access

    Anyone know of a way to solve my access problems or another way to do this?

    Thanks very much

    Flus
    Last edited by Flustor; Feb 3rd, 2003 at 11:32 AM.
    My Spidey senses are tingling!

  2. #2

    Thread Starter
    Lively Member Flustor's Avatar
    Join Date
    Sep 2001
    Location
    A small hole in Birmingham
    Posts
    76

    How to obtain Access table & column information

    Found out how to obtain the data I needed through the database object in VB:

    Get table name
    DatabaseObject.TableDefs(6).Name

    Get table type (0 = user defined table)
    DatabaseObject.TableDefs(6).Attributes

    Get field type
    10 = Text
    DatabaseObject.TableDefs(6).Fields(0).Type

    Get field size
    DatabaseObject.TableDefs(6).Fields(0).Size

    I've also found the Access table which stores object information (the equivalent of sysobjects in MSSql Server). It's called MSysObjects

    Outlined below are the codes and their meaning:
    Code:
    Column Name	 Column Type	 Column Size
    YesNo	                1	                 1
    Byte	                2	                 1
    Num Integer	3	                 2
    Num Long	                4	                 4
    Auto Number	4	                 4
    Currency	                5	                 8
    Num Single	6	                 4
    Num Double	7	                 8
    Date Time	                8	                 8
    Text(50)	               10	                 50
    Text(255)	               10	                 255
    Memo	               12	                 0
    My Spidey senses are tingling!

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Snippet - Determine Database Field Type

    VB Code:
    1. Sub FieldExample()
    2.  
    3.    Dim rs As ADODB.Recordset
    4.  
    5.    Dim fld As ADODB.Field
    6.  
    7.    Set rs = New ADODB.Recordset
    8.  
    9.    ' Open the recordset, specifying an SQL statement
    10.    ' and a connection string.
    11.  
    12.    rs.Open "Select * from authors", "DSN=pubs;UID=sa"
    13.    
    14.    Debug.Print "Fields in Authors Table:" & vbCr
    15.  
    16.    ' Loop through each Field object in the
    17.  
    18.    ' Fields collection of the table and display properties.
    19.  
    20.    For Each fld In rs.Fields
    21.  
    22.       Debug.Print "Name:  " & fld.Name & vbCr & _
    23.  
    24.             "Type:  " & fld.Type & vbCr & _
    25.             "Value: " & fld.Value
    26.  
    27.    Next fld
    28.  
    29.    ' Close the recordset.
    30.  
    31.    rs.Close
    32.  
    33. End Sub
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width