Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to dynamically create many datatables in c#.net

How to dynamically create many datatables in c#.net

Scheduled Pinned Locked Moved C#
csharptutorial
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AnilJayanti
    wrote on last edited by
    #1

    How to create many datatable dyanamically in c#.net. Thanks in Advance.

    B 1 Reply Last reply
    0
    • A AnilJayanti

      How to create many datatable dyanamically in c#.net. Thanks in Advance.

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Can you be more specific to your Qs/requirement? although at runtime time you can create datatable using DataTable class.Use google/msdn

      Cheers!! Brij

      A 1 Reply Last reply
      0
      • B Brij

        Can you be more specific to your Qs/requirement? although at runtime time you can create datatable using DataTable class.Use google/msdn

        Cheers!! Brij

        A Offline
        A Offline
        AnilJayanti
        wrote on last edited by
        #3

        Brij wrote:

        Brij wrote:

        I want to create datatabke array, where the array count will be statis and be declared in configuration. like . int iCount=4; for(x=1;x<=icount;x++) { // Here datatable object will be created dynamicall. like dt1,dt2.dt3.... DataTable dt+x =new DataTable(); // I want to add columns to the particular datatable. dt+x.columns.add("NO"); dt+x.columns.add("NAME .. } Thanks.

        B 1 Reply Last reply
        0
        • A AnilJayanti

          Brij wrote:

          Brij wrote:

          I want to create datatabke array, where the array count will be statis and be declared in configuration. like . int iCount=4; for(x=1;x<=icount;x++) { // Here datatable object will be created dynamicall. like dt1,dt2.dt3.... DataTable dt+x =new DataTable(); // I want to add columns to the particular datatable. dt+x.columns.add("NO"); dt+x.columns.add("NAME .. } Thanks.

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #4

          Why don't you use List?Use list of Datatable.Here you don't need to worry about the size.Create datatable at runtime and add to the list.Whenever you need you iterate the list and use them accordingly.

          Cheers!! Brij

          A 1 Reply Last reply
          0
          • B Brij

            Why don't you use List?Use list of Datatable.Here you don't need to worry about the size.Create datatable at runtime and add to the list.Whenever you need you iterate the list and use them accordingly.

            Cheers!! Brij

            A Offline
            A Offline
            AnilJayanti
            wrote on last edited by
            #5

            That's OK.But if I don't put the value in configuration then how would i know the count of datatables ???

            B 1 Reply Last reply
            0
            • A AnilJayanti

              That's OK.But if I don't put the value in configuration then how would i know the count of datatables ???

              B Offline
              B Offline
              Brij
              wrote on last edited by
              #6

              You can get the count from the list itself.You can store it some session variable (if user specific) or application varaiable(if application specific) for any other use. One thing How are you getting the count of the table.Is it coming at runtime?Can you be more specific to requirement?

              Cheers!! Brij

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups