By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,053 Members | 922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,053 IT Pros & Developers. It's quick & easy.

Getting data table parent child relations tostring?

P: n/a
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 strTableName 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 for tblCurrent?
--
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)
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Cor
Hi What a tool,

If you use a XML file that has the format of a dataset, you can read it in a
dataset, using by instance the dataset.readXML method

If it has not that format, you have to use it as a XML document.

If it is a dataset you can iterate trough the tables. Asuming you have only
one table you can do that like this (rought written not checked)

\\\
dim myRow as datarow
for each myRow in MyDataset.tables(0).rows
myItem = myrow.item("myitem")
next
///
But for that your XML file has to be a dataset.

If you have more tables you can do this of course also with the tables in a
dataset one by one iterating through the tables.

I hope this helps a little bit?

Cor

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.

Nov 20 '05 #2

P: n/a
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_Cons traints, 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)

"What-a-Tool" <Di************************@NoShitSherlock.Net> wrote in
message news:cQSyb.7287$Yt4.1778@lakeread05...
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 strTableName 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 for tblCurrent?
--
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)

Nov 20 '05 #3

P: n/a
"What-a-Tool" <Di************************@NoShitSherlock.Net>
schrieb
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_Cons traints,
New Object())

Dim f As New frmDG()

f.dg1.DataSource = dt

f.ShowDialog()

\\\

Did you enable Option Strict? In addition, I think the exception shows some
more info.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

P: n/a
Thanks to all who helped.
Got my solution from another helpful person in the ADO.Net group

Dim dt As New DataTable()

DsNew.Tables.Add(dt)

Con.Open()

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

Con.Close()

Dim f As New frmDG()

f.dg1.DataSource = dt

f.ShowDialog()

Had to add the {} after new object to make it an array of objects.
--

/ Sean the Mc /

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

"What-a-Tool" <Di************************@NoShitSherlock.Net> wrote in
message news:cQSyb.7287$Yt4.1778@lakeread05...
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 strTableName 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 for tblCurrent?
--
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)

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.