Getting parent/child relations to string

W

What-a-Tool

I am trying to write a program that will take all the members of a data
base, add them to a tree, with all child relations as sub-nodes.

I am having a problem getting the parent child relations for each table &
query.

Dim tblCurrent As DataTable

Dim strtblName As string

For Each tblCurrent In Ds1.Tables

strTableName = tblCurrent.TableName.ToString

Next



This gives me my table names. I can also get column names the same way.

..GetXMLSchema shows me what I want, but I don't want to even think about
dissecting that string data to make it usefull to me.

How can I get the name of any parent or child tables?


--
Thanks in advance for any help.

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
M

Miha Markic

Hi,

Top get referential constraints you will have to examine the
Table_Constraints schema (at least for Sql Server)
You'll get schema information in a DataTable by invoking:
DataTable dt =
oleDbConnection1.GetOleDbSchemaTable(OleDbSchemaGuid.Table_Constraints, new
object[]{});
 
W

What-a-Tool

I tried the following, but get an "invalid cast exception" on the "dt =
Con.GetOleDbSchemaTable..." line.

I'm using an Access DB.

Can anyone tell me whats wrong here? Thanks in Advance



///

Dim dt As New DataTable()

Ds1.Tables.Add(dt)

dt = Con.GetOleDbSchemaTable(OleDbSchemaGuid.Table_Constraints, New
Object())

Dim f As New frmDG()

f.dg1.DataSource = dt

f.ShowDialog()

\\\


--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
M

Miha Markic

Hi,

You should pass an array of objects not a single object:
New Object(){} instead of New Object()
 
W

What-a-Tool

Thank you very much - it now works!

Dim dt As New DataTable()

DsNew.Tables.Add(dt)

Con.Open()

dt = Con.GetOleDbSchemaTable(OleDbSchemaGuid.Table_Constraints, New Object()
{})

Con.Close()

Dim f As New frmDG()

f.dg1.DataSource = dt

f.ShowDialog()



--

/ Sean the Mc /



"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top