Multiple Table DataSet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • samoore33

    #1

    Multiple Table DataSet

    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("stat e"). It still looks for othe rows in
    the dataset.

    Dim myState As DataTable = myDataSet.Table s("state")
    Dim myTax As DataTable = myDataSet.Table s("Tax")
    Dim row As DataRow
    Dim column As DataColumn


    For Each myState In myDataSet.Table s
    For Each row In myState.Rows
    For Each column In myState.Columns
    txtList.Text += row("id").ToStr ing()
    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

  • Izzy

    #2
    Re: Multiple Table DataSet

    The reason for this is this line:

    For Each myState In myDataSet.Table s

    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.C ount - 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.ColumnNa me
    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("stat e"). It still looks for othe rows in
    the dataset.
    >
    Dim myState As DataTable = myDataSet.Table s("state")
    Dim myTax As DataTable = myDataSet.Table s("Tax")
    Dim row As DataRow
    Dim column As DataColumn
    >
    >
    For Each myState In myDataSet.Table s
    For Each row In myState.Rows
    For Each column In myState.Columns
    txtList.Text += row("id").ToStr ing()
    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

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Multiple Table DataSet

      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" <israel.richner @gmail.comschre ef in bericht
      news:1156194406 .568328.152040@ i42g2000cwa.goo glegroups.com.. .
      The reason for this is this line:
      >
      For Each myState In myDataSet.Table s
      >
      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.C ount - 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.ColumnNa me
      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("stat e"). It still looks for othe rows in
      >the dataset.
      >>
      >Dim myState As DataTable = myDataSet.Table s("state")
      > Dim myTax As DataTable = myDataSet.Table s("Tax")
      > Dim row As DataRow
      > Dim column As DataColumn
      >>
      >>
      > For Each myState In myDataSet.Table s
      > For Each row In myState.Rows
      > For Each column In myState.Columns
      > txtList.Text += row("id").ToStr ing()
      > 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
      >

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Multiple Table DataSet

        Scott,

        Why not just use a datagrid

        mydatagrid.data source = 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" <samoore33@gmai l.comschreef in bericht
        news:1156189758 .079549.240870@ m73g2000cwd.goo glegroups.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("stat e"). It still looks for othe rows in
        the dataset.
        >
        Dim myState As DataTable = myDataSet.Table s("state")
        Dim myTax As DataTable = myDataSet.Table s("Tax")
        Dim row As DataRow
        Dim column As DataColumn
        >
        >
        For Each myState In myDataSet.Table s
        For Each row In myState.Rows
        For Each column In myState.Columns
        txtList.Text += row("id").ToStr ing()
        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
        >

        Comment

        • Izzy

          #5
          Re: Multiple Table DataSet

          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" <israel.richner @gmail.comschre ef in bericht
          news:1156194406 .568328.152040@ i42g2000cwa.goo glegroups.com.. .
          The reason for this is this line:

          For Each myState In myDataSet.Table s

          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.C ount - 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.ColumnNa me
          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("stat e"). It still looks for othe rows in
          the dataset.
          >
          Dim myState As DataTable = myDataSet.Table s("state")
          Dim myTax As DataTable = myDataSet.Table s("Tax")
          Dim row As DataRow
          Dim column As DataColumn
          >
          >
          For Each myState In myDataSet.Table s
          For Each row In myState.Rows
          For Each column In myState.Columns
          txtList.Text += row("id").ToStr ing()
          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

          Comment

          • samoore33

            #6
            Re: Multiple Table DataSet

            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.data source = 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" <samoore33@gmai l.comschreef in bericht
            news:1156189758 .079549.240870@ m73g2000cwd.goo glegroups.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("stat e"). It still looks for othe rows in
            the dataset.

            Dim myState As DataTable = myDataSet.Table s("state")
            Dim myTax As DataTable = myDataSet.Table s("Tax")
            Dim row As DataRow
            Dim column As DataColumn


            For Each myState In myDataSet.Table s
            For Each row In myState.Rows
            For Each column In myState.Columns
            txtList.Text += row("id").ToStr ing()
            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

            Comment

            • Cor Ligthert [MVP]

              #7
              Re: Multiple Table DataSet

              Scott,

              And you know now how to do it?

              Cor

              "samoore33" <samoore33@gmai l.comschreef in bericht
              news:1156207566 .964878.75640@m 79g2000cwm.goog legroups.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.dat asource = 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" <samoore33@gmai l.comschreef in bericht
              >news:115618975 8.079549.240870 @m73g2000cwd.go oglegroups.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("stat e"). It still looks for othe rows in
              the dataset.
              >
              Dim myState As DataTable = myDataSet.Table s("state")
              Dim myTax As DataTable = myDataSet.Table s("Tax")
              Dim row As DataRow
              Dim column As DataColumn
              >
              >
              For Each myState In myDataSet.Table s
              For Each row In myState.Rows
              For Each column In myState.Columns
              txtList.Text += row("id").ToStr ing()
              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
              >
              >

              Comment

              • samoore33

                #8
                Re: Multiple Table DataSet

                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" <samoore33@gmai l.comschreef in bericht
                news:1156207566 .964878.75640@m 79g2000cwm.goog legroups.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.data source = 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" <samoore33@gmai l.comschreef in bericht
                news:1156189758 .079549.240870@ m73g2000cwd.goo glegroups.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("stat e"). It still looks for othe rows in
                the dataset.

                Dim myState As DataTable = myDataSet.Table s("state")
                Dim myTax As DataTable = myDataSet.Table s("Tax")
                Dim row As DataRow
                Dim column As DataColumn


                For Each myState In myDataSet.Table s
                For Each row In myState.Rows
                For Each column In myState.Columns
                txtList.Text += row("id").ToStr ing()
                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

                Comment

                Working...