Results 1 to 2 of 2

Thread: Table and Column references in Vb

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Sorry, I have posted this is general and got no response.

    I want to find out the Table and Column names in an Access database, referenced via a DSN. If the table is a certain name then I want to write out the columns, however I find when I do this that there are additional "column" names provided which are not part of my definition. Also I have no views / queries in the database so this isn't the source also.

    e.g. repl_test1 table
    ID AutoNumber
    Number Number
    On_Hold Yes/No
    Date_Start Date/Time

    with the following source:

    Private Sub Form_Load()

    Dim lc_connection As ADODB.Connection
    Dim lrs_tables As ADODB.Recordset
    Dim lrs_columns As ADODB.Recordset

    Dim ls_Connection As String

    Set lc_connection = New ADODB.Connection
    lc_connection.Open "DSN=TONY2"

    Set lrs_tables = lc_connection.OpenSchema(adSchemaTables)

    Do Until lrs_tables.EOF
    If lrs_tables!table_name = "repl_test1" Then
    Set lrs_columns = lc_connection.OpenSchema(adSchemaColumns)
    Do Until lrs_columns.EOF
    Debug.Print "Column Name: " & lrs_columns!COLUMN_NAME
    End If

    End Sub

    Column Name: Data
    Column Name: ID
    Column Name: ID
    Column Name: Number
    Column Name: on_hold
    Column Name: date_start

    As you can see two extra columns. If someone could answer:

    1. Where do these come from, and
    2. how do I get rid of them

    Any help appreciated.

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Ontario, Canada
    I believe those are Microsoft created objects of some sort. Maybe Index's or something.

    I have a sample project on my harddrive called "FindTableFieldNames" that acurately gets the names of tables and fields from a database. I assembled it from code i have collected.

    Email me at home if you want it.

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