datatable and dataset

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

    datatable and dataset

    I'd like to create a datatable and add rows to it, but not make it part of a
    dataset. so far i've not seen too many examples of this. I believe it can be
    done. does anyone know of an example?
    thanks
    kes
    --
    thanks (as always)
    some day i''m gona pay this forum back for all the help i''m getting
    kes
  • Marina

    #2
    Re: datatable and dataset

    here is a simple example in VB:

    Dim dt As New DataTable
    Dim dr As DataRow

    dt.Columns.Add( "MyNewColum n")

    For i As Integer = 1 to 5
    dr = dt.NewRow()
    dr("MyNewColumn ") = "value" & i
    dt.Rows.Add(dr)
    Next

    "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in message
    news:1FE183E8-910B-45F6-A487-A8AF516390FB@mi crosoft.com...[color=blue]
    > I'd like to create a datatable and add rows to it, but not make it part of
    > a
    > dataset. so far i've not seen too many examples of this. I believe it can
    > be
    > done. does anyone know of an example?
    > thanks
    > kes
    > --
    > thanks (as always)
    > some day i''m gona pay this forum back for all the help i''m getting
    > kes[/color]


    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: datatable and dataset

      kes,
      Here is an example that I just posted in response to another question:

      Dim table As New DataTable("RJN" )
      table.Columns.A dd("InstanceId" , GetType(Integer ))
      table.Columns.A dd("LevelId", GetType(Integer ))
      table.Columns.A dd("ParentId", GetType(Integer ))

      table.Rows.Add( New Object() {100, 1, Nothing})
      table.Rows.Add( New Object() {101, 2, 100})
      table.Rows.Add( New Object() {102, 3, 101})
      table.Rows.Add( New Object() {103, 4, 102})
      table.Rows.Add( New Object() {104, 5, 103})
      table.Rows.Add( New Object() {105, 5, 104})
      table.Rows.Add( New Object() {106, 5, 104})


      The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002 &
      2003) do not support the ReadXml & WriteXml methods. I understand that .NET
      2.0 (VS.NET 2005) will add support for these methods ot DataTable.

      Hope this helps
      Jay

      "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in message
      news:1FE183E8-910B-45F6-A487-A8AF516390FB@mi crosoft.com...
      | I'd like to create a datatable and add rows to it, but not make it part of
      a
      | dataset. so far i've not seen too many examples of this. I believe it can
      be
      | done. does anyone know of an example?
      | thanks
      | kes
      | --
      | thanks (as always)
      | some day i''m gona pay this forum back for all the help i''m getting
      | kes


      Comment

      • WebBuilder451

        #4
        Re: datatable and dataset

        thanks
        related question: i'm trying to bind this to a dropdown list
        i'm trying
        Me.ddlMemType.D ataSource = table.TableName
        Me.ddlMemType.D ataTextField = ....
        this does not work. how would i do this?
        thnaks
        kes
        --
        thanks (as always)
        some day i''m gona pay this forum back for all the help i''m getting
        kes


        "Jay B. Harlow [MVP - Outlook]" wrote:
        [color=blue]
        > kes,
        > Here is an example that I just posted in response to another question:
        >
        > Dim table As New DataTable("RJN" )
        > table.Columns.A dd("InstanceId" , GetType(Integer ))
        > table.Columns.A dd("LevelId", GetType(Integer ))
        > table.Columns.A dd("ParentId", GetType(Integer ))
        >
        > table.Rows.Add( New Object() {100, 1, Nothing})
        > table.Rows.Add( New Object() {101, 2, 100})
        > table.Rows.Add( New Object() {102, 3, 101})
        > table.Rows.Add( New Object() {103, 4, 102})
        > table.Rows.Add( New Object() {104, 5, 103})
        > table.Rows.Add( New Object() {105, 5, 104})
        > table.Rows.Add( New Object() {106, 5, 104})
        >
        >
        > The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002 &
        > 2003) do not support the ReadXml & WriteXml methods. I understand that .NET
        > 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
        >
        > Hope this helps
        > Jay
        >
        > "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in message
        > news:1FE183E8-910B-45F6-A487-A8AF516390FB@mi crosoft.com...
        > | I'd like to create a datatable and add rows to it, but not make it part of
        > a
        > | dataset. so far i've not seen too many examples of this. I believe it can
        > be
        > | done. does anyone know of an example?
        > | thanks
        > | kes
        > | --
        > | thanks (as always)
        > | some day i''m gona pay this forum back for all the help i''m getting
        > | kes
        >
        >
        >[/color]

        Comment

        • W.G. Ryan MVP

          #5
          Re: datatable and dataset

          just change it to Me.ddlMemType.D ataSource= table
          Me.ddlMemType.D ataTextField = "FieldName"
          "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in message
          news:A80227C5-BDED-4960-9AFE-DD8181F92D83@mi crosoft.com...[color=blue]
          > thanks
          > related question: i'm trying to bind this to a dropdown list
          > i'm trying
          > Me.ddlMemType.D ataSource = table.TableName
          > Me.ddlMemType.D ataTextField = ....
          > this does not work. how would i do this?
          > thnaks
          > kes
          > --
          > thanks (as always)
          > some day i''m gona pay this forum back for all the help i''m getting
          > kes
          >
          >
          > "Jay B. Harlow [MVP - Outlook]" wrote:
          >[color=green]
          >> kes,
          >> Here is an example that I just posted in response to another question:
          >>
          >> Dim table As New DataTable("RJN" )
          >> table.Columns.A dd("InstanceId" , GetType(Integer ))
          >> table.Columns.A dd("LevelId", GetType(Integer ))
          >> table.Columns.A dd("ParentId", GetType(Integer ))
          >>
          >> table.Rows.Add( New Object() {100, 1, Nothing})
          >> table.Rows.Add( New Object() {101, 2, 100})
          >> table.Rows.Add( New Object() {102, 3, 101})
          >> table.Rows.Add( New Object() {103, 4, 102})
          >> table.Rows.Add( New Object() {104, 5, 103})
          >> table.Rows.Add( New Object() {105, 5, 104})
          >> table.Rows.Add( New Object() {106, 5, 104})
          >>
          >>
          >> The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002
          >> &
          >> 2003) do not support the ReadXml & WriteXml methods. I understand that
          >> .NET
          >> 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
          >>
          >> Hope this helps
          >> Jay
          >>
          >> "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in
          >> message
          >> news:1FE183E8-910B-45F6-A487-A8AF516390FB@mi crosoft.com...
          >> | I'd like to create a datatable and add rows to it, but not make it part
          >> of
          >> a
          >> | dataset. so far i've not seen too many examples of this. I believe it
          >> can
          >> be
          >> | done. does anyone know of an example?
          >> | thanks
          >> | kes
          >> | --
          >> | thanks (as always)
          >> | some day i''m gona pay this forum back for all the help i''m getting
          >> | kes
          >>
          >>
          >>[/color][/color]


          Comment

          • Jay B. Harlow [MVP - Outlook]

            #6
            Re: datatable and dataset

            Kes,
            As W.G. Ryan states:

            Bind only the DataTable itself to the DataSource.

            | Me.ddlMemType.D ataSource = table
            | Me.ddlMemType.D ataTextField = ....

            By setting the DataSource = table.TableName you were attempting to bind to a
            String...

            Hope this helps
            Jay

            "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in message
            news:A80227C5-BDED-4960-9AFE-DD8181F92D83@mi crosoft.com...
            | thanks
            | related question: i'm trying to bind this to a dropdown list
            | i'm trying
            | Me.ddlMemType.D ataSource = table.TableName
            | Me.ddlMemType.D ataTextField = ....
            | this does not work. how would i do this?
            | thnaks
            | kes
            | --
            | thanks (as always)
            | some day i''m gona pay this forum back for all the help i''m getting
            | kes
            |
            |
            | "Jay B. Harlow [MVP - Outlook]" wrote:
            |
            | > kes,
            | > Here is an example that I just posted in response to another question:
            | >
            | > Dim table As New DataTable("RJN" )
            | > table.Columns.A dd("InstanceId" , GetType(Integer ))
            | > table.Columns.A dd("LevelId", GetType(Integer ))
            | > table.Columns.A dd("ParentId", GetType(Integer ))
            | >
            | > table.Rows.Add( New Object() {100, 1, Nothing})
            | > table.Rows.Add( New Object() {101, 2, 100})
            | > table.Rows.Add( New Object() {102, 3, 101})
            | > table.Rows.Add( New Object() {103, 4, 102})
            | > table.Rows.Add( New Object() {104, 5, 103})
            | > table.Rows.Add( New Object() {105, 5, 104})
            | > table.Rows.Add( New Object() {106, 5, 104})
            | >
            | >
            | > The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002
            &
            | > 2003) do not support the ReadXml & WriteXml methods. I understand that
            ..NET
            | > 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
            | >
            | > Hope this helps
            | > Jay
            | >
            | > "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in
            message
            | > news:1FE183E8-910B-45F6-A487-A8AF516390FB@mi crosoft.com...
            | > | I'd like to create a datatable and add rows to it, but not make it
            part of
            | > a
            | > | dataset. so far i've not seen too many examples of this. I believe it
            can
            | > be
            | > | done. does anyone know of an example?
            | > | thanks
            | > | kes
            | > | --
            | > | thanks (as always)
            | > | some day i''m gona pay this forum back for all the help i''m getting
            | > | kes
            | >
            | >
            | >


            Comment

            • WebBuilder451

              #7
              Re: datatable and dataset

              thank you both for replying
              this works!!
              it seems its the simple ones that cause me the most greif!!!
              --
              thanks (as always)
              some day i''m gona pay this forum back for all the help i''m getting
              kes


              "W.G. Ryan MVP" wrote:
              [color=blue]
              > just change it to Me.ddlMemType.D ataSource= table
              > Me.ddlMemType.D ataTextField = "FieldName"
              > "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in message
              > news:A80227C5-BDED-4960-9AFE-DD8181F92D83@mi crosoft.com...[color=green]
              > > thanks
              > > related question: i'm trying to bind this to a dropdown list
              > > i'm trying
              > > Me.ddlMemType.D ataSource = table.TableName
              > > Me.ddlMemType.D ataTextField = ....
              > > this does not work. how would i do this?
              > > thnaks
              > > kes
              > > --
              > > thanks (as always)
              > > some day i''m gona pay this forum back for all the help i''m getting
              > > kes
              > >
              > >
              > > "Jay B. Harlow [MVP - Outlook]" wrote:
              > >[color=darkred]
              > >> kes,
              > >> Here is an example that I just posted in response to another question:
              > >>
              > >> Dim table As New DataTable("RJN" )
              > >> table.Columns.A dd("InstanceId" , GetType(Integer ))
              > >> table.Columns.A dd("LevelId", GetType(Integer ))
              > >> table.Columns.A dd("ParentId", GetType(Integer ))
              > >>
              > >> table.Rows.Add( New Object() {100, 1, Nothing})
              > >> table.Rows.Add( New Object() {101, 2, 100})
              > >> table.Rows.Add( New Object() {102, 3, 101})
              > >> table.Rows.Add( New Object() {103, 4, 102})
              > >> table.Rows.Add( New Object() {104, 5, 103})
              > >> table.Rows.Add( New Object() {105, 5, 104})
              > >> table.Rows.Add( New Object() {106, 5, 104})
              > >>
              > >>
              > >> The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002
              > >> &
              > >> 2003) do not support the ReadXml & WriteXml methods. I understand that
              > >> .NET
              > >> 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
              > >>
              > >> Hope this helps
              > >> Jay
              > >>
              > >> "WebBuilder 451" <WebBuilder451@ discussions.mic rosoft.com> wrote in
              > >> message
              > >> news:1FE183E8-910B-45F6-A487-A8AF516390FB@mi crosoft.com...
              > >> | I'd like to create a datatable and add rows to it, but not make it part
              > >> of
              > >> a
              > >> | dataset. so far i've not seen too many examples of this. I believe it
              > >> can
              > >> be
              > >> | done. does anyone know of an example?
              > >> | thanks
              > >> | kes
              > >> | --
              > >> | thanks (as always)
              > >> | some day i''m gona pay this forum back for all the help i''m getting
              > >> | kes
              > >>
              > >>
              > >>[/color][/color]
              >
              >
              >[/color]

              Comment

              Working...