create datatable at runtime

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

    #1

    create datatable at runtime

    Hi Group,
    i'd like to create 10 datatables at runtime
    something like this

    for (int i=1; i<11;i++)
    {
    DataTable i.ToString() = new DataTable()
    }

    How can I do it?

    TIA

    Peter


  • Melih Odabaþ

    #2
    Re: create datatable at runtime

    You can create a dataset:

    DataSet ds = new DataSet();

    then in the loop:

    for (int i = 1; i<11; i++)
    {
    ds.Tables.Add(i .ToString()); //Not sure of line of code, but should be
    something like it.
    ....
    }

    Hope this helps.


    "LPeter" <nospam@nospam. local> wrote in message
    news:eeYHBNNZDH A.1816@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi Group,
    > i'd like to create 10 datatables at runtime
    > something like this
    >
    > for (int i=1; i<11;i++)
    > {
    > DataTable i.ToString() = new DataTable()
    > }
    >
    > How can I do it?
    >
    > TIA
    >
    > Peter
    >
    >[/color]


    Comment

    • LPeter

      #3
      Re: create datatable at runtime

      Hi Melih,
      your trick works very well

      Thank you
      Peter

      "Melih Odabaþ" <melih_odabas@y ahoo.com (no spam)> wrote in message
      news:eT8%23O2OZ DHA.652@tk2msft ngp13.phx.gbl.. .[color=blue]
      > You can create a dataset:
      >
      > DataSet ds = new DataSet();
      >
      > then in the loop:
      >
      > for (int i = 1; i<11; i++)
      > {
      > ds.Tables.Add(i .ToString()); //Not sure of line of code, but should be
      > something like it.
      > ...
      > }
      >
      > Hope this helps.
      >
      >
      > "LPeter" <nospam@nospam. local> wrote in message
      > news:eeYHBNNZDH A.1816@TK2MSFTN GP09.phx.gbl...[color=green]
      > > Hi Group,
      > > i'd like to create 10 datatables at runtime
      > > something like this
      > >
      > > for (int i=1; i<11;i++)
      > > {
      > > DataTable i.ToString() = new DataTable()
      > > }
      > >
      > > How can I do it?
      > >
      > > TIA
      > >
      > > Peter
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...