View relations of a table 
Author Message
 View relations of a table

Hallo,

Can someone help me,

How to put the relations of my selected table in a list box.

my code:

    Dim dbsNorthwind As Database
    Dim fldTableDef As TableDef
    Dim veld As Field
    Dim a As Integer
    Dim b As Integer

Private Sub Command1_Click()

'Here i put all the tables of nwind.mdb in listbox1

Set x = OpenDatabase("C:\Program files\Devstudio\VB\nwind.mdb")
For a = 1 To x.TableDefs.Count
List1.AddItem (x.TableDefs(a - 1).Name)
List1.ItemData(List1.NewIndex) = a - 1
Next
x.Close
End Sub

Private Sub List1_Click()

Set x = OpenDatabase("C:\Program files\Devstudio\VB\nwind.mdb")

' here i have to put al the ralation tables from the selected table in
listbox2

How to do?  i have no idee.
some hints please.

' here i put al the fields fro the selected table in listbox3

List3.Clear
t = List1.ListIndex
For b = 1 To x.TableDefs(t).Fields.Count
 List3.AddItem (x.TableDefs(t).Fields(b - 1).Name)
Next b

End Sub



Fri, 18 May 2001 03:00:00 GMT  
 View relations of a table
(From the Relations example in the VB help file)

With dbsNorthwind.Relations!CategoriesProducts
                Debug.Print "Properties of " & .Name & " Relation"

Debug.Print "    Table = " & .Table
                Debug.Print "    ForeignTable = " & .ForeignTable
                Debug.Print "Fields of " & .Name & " Relation"
                With .Fields!CategoryID
                        Debug.Print "    " & .Name
                        Debug.Print "        Name = " & .Name
                        Debug.Print "        ForeignName = " & .ForeignName
                End With
        End With

Should give you a head start... Enclose this loop within a "For Each Relation in
Relations" for the database, and then add another simpliar loop for all fields in the
relation.

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please post/reply to the newsgroup(s) so
that everyone can benefit from the discussion.

Regards,

Klaus H. Probst, MCP


       ICQ: 22454937
~~~~~~~~~~~~~~~~~~~~~~~~~~~



Quote:
> Hallo,

> Can someone help me,

> How to put the relations of my selected table in a list box.

> my code:

>     Dim dbsNorthwind As Database
>     Dim fldTableDef As TableDef
>     Dim veld As Field
>     Dim a As Integer
>     Dim b As Integer

> Private Sub Command1_Click()

> 'Here i put all the tables of nwind.mdb in listbox1

> Set x = OpenDatabase("C:\Program files\Devstudio\VB\nwind.mdb")
> For a = 1 To x.TableDefs.Count
> List1.AddItem (x.TableDefs(a - 1).Name)
> List1.ItemData(List1.NewIndex) = a - 1
> Next
> x.Close
> End Sub

> Private Sub List1_Click()

> Set x = OpenDatabase("C:\Program files\Devstudio\VB\nwind.mdb")

> ' here i have to put al the ralation tables from the selected table in
> listbox2

> How to do?  i have no idee.
> some hints please.

> ' here i put al the fields fro the selected table in listbox3

> List3.Clear
> t = List1.ListIndex
> For b = 1 To x.TableDefs(t).Fields.Count
>  List3.AddItem (x.TableDefs(t).Fields(b - 1).Name)
> Next b

> End Sub



Fri, 18 May 2001 03:00:00 GMT  
 View relations of a table

Hmmm... I don't think you can do this from ADO... but why would you want to? Can't you
use DAO? Things like relationships are defined internally by database engines, and (IMO)
are not meant to be accessed by non-native consumers (which is what ADO is in this case),
which should be restricted to reading and writing data. Did you ever pull relationship
information from an Oracle server using ODBC? I don't think so. DAO is designed and meant
to plug directly into the Jet engine, thus it has the most direct, low-level (if you can
call it that) access to Jet's internal workings.

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please post/reply to the newsgroup(s) so
that everyone can benefit from the discussion.

Regards,

Klaus H. Probst, MCP


       ICQ: 22454937
~~~~~~~~~~~~~~~~~~~~~~~~~~~



Quote:
> And how can we do this via ADO?  I'd like a method that works
> for all instances of Jet/Access via OLE-DB, Jet/Access via ODBC,
> SQL Server and Oracle.

> Seems like I have to do different things for each provider,
> including using DAO instead of ADO for Jet.  Aaarrggh.  It seems
> 'Universal Data Access' was named a little prematurely and I
> need to wait for 'Comsic Data Access'.  Does anyone have any
> useful suggestions?

> Cheers!
>    Trevor.



> > (From the Relations example in the VB help file)

> > With dbsNorthwind.Relations!CategoriesProducts
> >               Debug.Print "Properties of " & .Name & " Relation"

> > Debug.Print "    Table = " & .Table
> >               Debug.Print "    ForeignTable = " & .ForeignTable
> >               Debug.Print "Fields of " & .Name & " Relation"
> >               With .Fields!CategoryID
> >                       Debug.Print "    " & .Name
> >                       Debug.Print "        Name = " & .Name
> >                       Debug.Print "        ForeignName = " & .ForeignName
> >               End With
> >       End With

> > Should give you a head start... Enclose this loop within a "For Each Relation in
> > Relations" for the database, and then add another simpliar loop for all fields in the
> > relation.

> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Please post/reply to the newsgroup(s) so
> > that everyone can benefit from the discussion.

> > Regards,

> > Klaus H. Probst, MCP


> >        ICQ: 22454937
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~



> > > Hallo,

> > > Can someone help me,

> > > How to put the relations of my selected table in a list box.

> > > my code:

> > >     Dim dbsNorthwind As Database
> > >     Dim fldTableDef As TableDef
> > >     Dim veld As Field
> > >     Dim a As Integer
> > >     Dim b As Integer

> > > Private Sub Command1_Click()

> > > 'Here i put all the tables of nwind.mdb in listbox1



Sun, 20 May 2001 03:00:00 GMT  
 View relations of a table
And how can we do this via ADO?  I'd like a method that works
for all instances of Jet/Access via OLE-DB, Jet/Access via ODBC,
SQL Server and Oracle.

Seems like I have to do different things for each provider,
including using DAO instead of ADO for Jet.  Aaarrggh.  It seems
'Universal Data Access' was named a little prematurely and I
need to wait for 'Comsic Data Access'.  Does anyone have any
useful suggestions?

Cheers!
        Trevor.



Quote:
> (From the Relations example in the VB help file)

> With dbsNorthwind.Relations!CategoriesProducts
>            Debug.Print "Properties of " & .Name & " Relation"

> Debug.Print "    Table = " & .Table
>            Debug.Print "    ForeignTable = " & .ForeignTable
>            Debug.Print "Fields of " & .Name & " Relation"
>            With .Fields!CategoryID
>                    Debug.Print "    " & .Name
>                    Debug.Print "        Name = " & .Name
>                    Debug.Print "        ForeignName = " & .ForeignName
>            End With
>    End With

> Should give you a head start... Enclose this loop within a "For Each Relation in
> Relations" for the database, and then add another simpliar loop for all fields in the
> relation.

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Please post/reply to the newsgroup(s) so
> that everyone can benefit from the discussion.

> Regards,

> Klaus H. Probst, MCP


>        ICQ: 22454937
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~



> > Hallo,

> > Can someone help me,

> > How to put the relations of my selected table in a list box.

> > my code:

> >     Dim dbsNorthwind As Database
> >     Dim fldTableDef As TableDef
> >     Dim veld As Field
> >     Dim a As Integer
> >     Dim b As Integer

> > Private Sub Command1_Click()

> > 'Here i put all the tables of nwind.mdb in listbox1



Mon, 21 May 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. View relations of a table

2. Relations between tables n:m-relation

3. Save nodes and their relations in a tree view object (to Neila)

4. Save nodes and their relations in a tree view object

5. Form View/Table View

6. Altering relations of two tables

7. Modify relation between tables

8. Relations between several hundret tables

9. question about Dataset relation and tables

10. relation between 2 tables

11. Table relations ships

12. Question with Table Relation

 

 
Powered by phpBB® Forum Software