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

Multiple Table DataSet

P: n/a
I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore

Aug 21 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
The reason for this is this line:

For Each myState In myDataSet.Tables

Even though your setting it to a specific table, this line sets it to
each table in the dataset starting with table(0).

When you say you want to list all the ITEMS do you mean data in the
columns or do you want to list the column names?

This is how you list the data in each column in a table.

Dim table As DataTable = dataset.tables("Whatever")
Dim row As DataRow
Dim b As Byte

For Each row In table.Rows
For b = 0 To table.Columns.Count - 1
TextBox1.Text = TextBox1.Text & row(b)
Next
Next
This is how you list each column name in the table.

Dim table As DataTable
Dim row As DataRow
Dim column As DataColumn

For Each row In table.Rows
For Each column In table.Columns
TextBox1.Text = TextBox1.Text & column.ColumnName
Next
Next

samoore33 wrote:
I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore
Aug 21 '06 #2

P: n/a
Izzy,

You know that it is more expensive to take a byte as indexer.
The cheapest one one a 32bit system is the integer (int32).

(Your process to set it in the accumulator register takes more than that 3
bytes that you think to save).

Cor

"Izzy" <is************@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
The reason for this is this line:

For Each myState In myDataSet.Tables

Even though your setting it to a specific table, this line sets it to
each table in the dataset starting with table(0).

When you say you want to list all the ITEMS do you mean data in the
columns or do you want to list the column names?

This is how you list the data in each column in a table.

Dim table As DataTable = dataset.tables("Whatever")
Dim row As DataRow
Dim b As Byte

For Each row In table.Rows
For b = 0 To table.Columns.Count - 1
TextBox1.Text = TextBox1.Text & row(b)
Next
Next
This is how you list each column name in the table.

Dim table As DataTable
Dim row As DataRow
Dim column As DataColumn

For Each row In table.Rows
For Each column In table.Columns
TextBox1.Text = TextBox1.Text & column.ColumnName
Next
Next

samoore33 wrote:
>I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore

Aug 21 '06 #3

P: n/a
Scott,

Why not just use a datagrid

mydatagrid.datasource = myDataset

Otherwise you have to loop through this set which all contains collections
dataset (has a collection of datatables with the name tables)
datatables (has a collecion of datarows with the name rows
datarows (has a collection of items which are the default)

All the collections have a count, while they all can be indexed by an
integer.

I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
>I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore

Aug 21 '06 #4

P: n/a
Didn't know that, thanks Cor.

I have some code to change.
Cor Ligthert [MVP] wrote:
Izzy,

You know that it is more expensive to take a byte as indexer.
The cheapest one one a 32bit system is the integer (int32).

(Your process to set it in the accumulator register takes more than that 3
bytes that you think to save).

Cor

"Izzy" <is************@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
The reason for this is this line:

For Each myState In myDataSet.Tables

Even though your setting it to a specific table, this line sets it to
each table in the dataset starting with table(0).

When you say you want to list all the ITEMS do you mean data in the
columns or do you want to list the column names?

This is how you list the data in each column in a table.

Dim table As DataTable = dataset.tables("Whatever")
Dim row As DataRow
Dim b As Byte

For Each row In table.Rows
For b = 0 To table.Columns.Count - 1
TextBox1.Text = TextBox1.Text & row(b)
Next
Next
This is how you list each column name in the table.

Dim table As DataTable
Dim row As DataRow
Dim column As DataColumn

For Each row In table.Rows
For Each column In table.Columns
TextBox1.Text = TextBox1.Text & column.ColumnName
Next
Next

samoore33 wrote:
I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore
Aug 21 '06 #5

P: n/a
Cor,

Believe me I would love to use a datagrid, I have a lot more experience
with datagrids. They want the information to populate a text box rather
then a datagrid.

Fun fun fun

Scott

Cor Ligthert [MVP] wrote:
Scott,

Why not just use a datagrid

mydatagrid.datasource = myDataset

Otherwise you have to loop through this set which all contains collections
dataset (has a collection of datatables with the name tables)
datatables (has a collecion of datarows with the name rows
datarows (has a collection of items which are the default)

All the collections have a count, while they all can be indexed by an
integer.

I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore
Aug 22 '06 #6

P: n/a
Scott,

And you know now how to do it?

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11*********************@m79g2000cwm.googlegro ups.com...
Cor,

Believe me I would love to use a datagrid, I have a lot more experience
with datagrids. They want the information to populate a text box rather
then a datagrid.

Fun fun fun

Scott

Cor Ligthert [MVP] wrote:
>Scott,

Why not just use a datagrid

mydatagrid.datasource = myDataset

Otherwise you have to loop through this set which all contains
collections
dataset (has a collection of datatables with the name tables)
datatables (has a collecion of datarows with the name rows
datarows (has a collection of items which are the default)

All the collections have a count, while they all can be indexed by an
integer.

I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googleg roups.com...
>I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore

Aug 22 '06 #7

P: n/a
Cor,

Yes. I used what Izzy gave me to figure it out. I really do appreciate
the help from both Izzy and you.

Thanks a lot!

Scott

Cor Ligthert [MVP] wrote:
Scott,

And you know now how to do it?

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11*********************@m79g2000cwm.googlegro ups.com...
Cor,

Believe me I would love to use a datagrid, I have a lot more experience
with datagrids. They want the information to populate a text box rather
then a datagrid.

Fun fun fun

Scott

Cor Ligthert [MVP] wrote:
Scott,

Why not just use a datagrid

mydatagrid.datasource = myDataset

Otherwise you have to loop through this set which all contains
collections
dataset (has a collection of datatables with the name tables)
datatables (has a collecion of datarows with the name rows
datarows (has a collection of items which are the default)

All the collections have a count, while they all can be indexed by an
integer.

I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for othe rows in
the dataset.

Dim myState As DataTable = myDataSet.Tables("state")
Dim myTax As DataTable = myDataSet.Tables("Tax")
Dim row As DataRow
Dim column As DataColumn
For Each myState In myDataSet.Tables
For Each row In myState.Rows
For Each column In myState.Columns
txtList.Text += row("id").ToString()
Next
Next
Next

A friend sent me some code that parses the DataSet and shows me the
structure of it. The first table is called "state" and the third table
is called "Tax".

Any help would be appreciated.

Scott Moore
Aug 22 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.