Home All Groups Group Topic Archive Search About

Get table names from MSAccess Datasource

Author
17 Apr 2006 8:40 PM
Steven Smith
Hello all,

I have a vb6 (not .NET) program using MS Access as the backend. As part of
an import form, I need to allow the user to select the table containing the
data to be imported. How can I populate a combo with this information?
Then, once this value is selected, how can I populate other combos with the
column names of the selected table?


Thanks,

Steven Smith

Author
17 Apr 2006 11:53 PM
Ken Tucker [MVP]
Hi,

        Maybe this will help.

http://www.vb-tips.com/default.aspx?ID=26f91edd-044c-4e71-8c6c-e9d7983c1e05

Ken
----------------
Show quoteHide quote
"Steven Smith" <slu***@webbox.com> wrote in message
news:73T0g.2504$LG.31@twister.nyroc.rr.com...
> Hello all,
>
> I have a vb6 (not .NET) program using MS Access as the backend. As part of
> an import form, I need to allow the user to select the table containing
> the
> data to be imported. How can I populate a combo with this information?
> Then, once this value is selected, how can I populate other combos with
> the
> column names of the selected table?
>
>
> Thanks,
>
> Steven Smith
>
Author
18 Apr 2006 2:52 AM
Steven Smith
Thanks Ken... it wasn't quite what I needed, but it pointed me in the right
direction.



Show quoteHide quote
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in
news:eZe9uonYGHA.3684@TK2MSFTNGP05.phx.gbl:

> Hi,
>
>         Maybe this will help.
>
> http://www.vb-tips.com/default.aspx?ID=26f91edd-044c-4e71-8c6c-e9d7983c
> 1e05
>
> Ken
> ----------------
> "Steven Smith" <slu***@webbox.com> wrote in message
> news:73T0g.2504$LG.31@twister.nyroc.rr.com...
>> Hello all,
>>
>> I have a vb6 (not .NET) program using MS Access as the backend. As
>> part of an import form, I need to allow the user to select the table
>> containing the
>> data to be imported. How can I populate a combo with this
>> information? Then, once this value is selected, how can I populate
>> other combos with the
>> column names of the selected table?
>>
>>
>> Thanks,
>>
>> Steven Smith
>>
>
>
Author
18 Apr 2006 5:07 AM
Cor Ligthert [MVP]
Steven,

Somebody else was asking the same question, maybe we should extend our
sample with the schema information.

http://msdn2.microsoft.com/en-us/library/kcax58fh(VS.80).aspx

But using that sample the schema option easy to find and it works the same..

I hope this helps,

Cor

Show quoteHide quote
"Steven Smith" <slu***@webbox.com> schreef in bericht
news:_vY0g.2742$u27.940@twister.nyroc.rr.com...
> Thanks Ken... it wasn't quite what I needed, but it pointed me in the
> right
> direction.
>
>
>
> "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in
> news:eZe9uonYGHA.3684@TK2MSFTNGP05.phx.gbl:
>
>> Hi,
>>
>>         Maybe this will help.
>>
>> http://www.vb-tips.com/default.aspx?ID=26f91edd-044c-4e71-8c6c-e9d7983c
>> 1e05
>>
>> Ken
>> ----------------
>> "Steven Smith" <slu***@webbox.com> wrote in message
>> news:73T0g.2504$LG.31@twister.nyroc.rr.com...
>>> Hello all,
>>>
>>> I have a vb6 (not .NET) program using MS Access as the backend. As
>>> part of an import form, I need to allow the user to select the table
>>> containing the
>>> data to be imported. How can I populate a combo with this
>>> information? Then, once this value is selected, how can I populate
>>> other combos with the
>>> column names of the selected table?
>>>
>>>
>>> Thanks,
>>>
>>> Steven Smith
>>>
>>
>>
>
Author
18 Apr 2006 5:09 AM
Cor Ligthert [MVP]
>
> Somebody else was asking the same question, maybe we should extend our
> sample with the schema information.
>
I forgot to type it complete, therefore the link was still in my clipboard.
Author
18 Apr 2006 1:31 PM
Paul Clement
On Mon, 17 Apr 2006 20:40:35 GMT, Steven Smith <slu***@webbox.com> wrote:

¤ Hello all,
¤
¤ I have a vb6 (not .NET) program using MS Access as the backend. As part of
¤ an import form, I need to allow the user to select the table containing the
¤ data to be imported. How can I populate a combo with this information?
¤ Then, once this value is selected, how can I populate other combos with the
¤ column names of the selected table?
¤

List of Tables:

        Dim DatabaseConnection As New System.Data.OleDb.OleDbConnection
        Dim SchemaTable As DataTable

        DatabaseConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                              "Data Source=C:\Test Files\db1 XP.mdb"

        DatabaseConnection.Open()

        SchemaTable =
DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, _
                                                            New Object() {Nothing, Nothing, Nothing,
Nothing})

        Dim RowCount As Int32
        For RowCount = 0 To SchemaTable.Rows.Count - 1
            TableListCombo.Items.Add(SchemaTable.Rows(RowCount)!TABLE_NAME.ToString)
        Next RowCount

        DatabaseConnection.Close()

List of Columns:

        Dim DatabaseConnection As New System.Data.OleDb.OleDbConnection
        Dim SchemaTable As DataTable

        DatabaseConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                              "Data Source=C:\Test Files\db1 XP.mdb"

        DatabaseConnection.Open()

        SchemaTable =
DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, _
                            New Object() {Nothing, Nothing, "Table1"})

        Dim RowCount As Int32
        For RowCount = 0 To SchemaTable.Rows.Count - 1
            ColumnListCombo.Items.Add(SchemaTable.Rows(RowCount)!COLUMN_NAME.ToString)
        Next RowCount

        DatabaseConnection.Close()


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
18 Apr 2006 4:29 PM
Steven Smith
Thanks!


Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote in
Show quoteHide quote
news:afq942loajeenhonpml7a8hdudsu20hg1m@4ax.com:

> On Mon, 17 Apr 2006 20:40:35 GMT, Steven Smith <slu***@webbox.com>
> wrote:
>
> ¤ Hello all,
> ¤
> ¤ I have a vb6 (not .NET) program using MS Access as the backend. As
> part of ¤ an import form, I need to allow the user to select the table
> containing the ¤ data to be imported. How can I populate a combo with
> this information? ¤ Then, once this value is selected, how can I
> populate other combos with the ¤ column names of the selected table?
> ¤
>
> List of Tables:
>
>         Dim DatabaseConnection As New
>         System.Data.OleDb.OleDbConnection Dim SchemaTable As DataTable
>
>         DatabaseConnection.ConnectionString =
>         "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>                               "Data Source=C:\Test Files\db1 XP.mdb"
>
>         DatabaseConnection.Open()
>
>         SchemaTable =
> DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGui
> d.Tables, _
>                                                             New
>                               Object() {Nothing, Nothing, Nothing,
> Nothing})
>
>         Dim RowCount As Int32
>         For RowCount = 0 To SchemaTable.Rows.Count - 1
>             TableListCombo.Items.Add(SchemaTable.Rows(RowCount)!TABLE_N
>             AME.ToString)
>         Next RowCount
>
>         DatabaseConnection.Close()
>
> List of Columns:
>
>         Dim DatabaseConnection As New
>         System.Data.OleDb.OleDbConnection Dim SchemaTable As DataTable
>
>         DatabaseConnection.ConnectionString =
>         "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>                               "Data Source=C:\Test Files\db1 XP.mdb"
>
>         DatabaseConnection.Open()
>
>         SchemaTable =
> DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGui
> d.Columns, _
>                             New Object() {Nothing, Nothing, "Table1"})
>
>         Dim RowCount As Int32
>         For RowCount = 0 To SchemaTable.Rows.Count - 1
>             ColumnListCombo.Items.Add(SchemaTable.Rows(RowCount)!COLUMN
>             _NAME.ToString)
>         Next RowCount
>
>         DatabaseConnection.Close()
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)