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. Visual Basic
  4. How to get data in column from dataset

How to get data in column from dataset

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
10 Posts 3 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.
  • S Offline
    S Offline
    somchoto
    wrote on last edited by
    #1

    How to get data in column from dataset? i have data in dataset and i want data from some column in dataset.

    S T S 4 Replies Last reply
    0
    • S somchoto

      How to get data in column from dataset? i have data in dataset and i want data from some column in dataset.

      S Offline
      S Offline
      Sonia Gupta
      wrote on last edited by
      #2

      dataset.tables(0).row(0).column(0).item(0).tostring()

      1 Reply Last reply
      0
      • S somchoto

        How to get data in column from dataset? i have data in dataset and i want data from some column in dataset.

        T Offline
        T Offline
        theScorp
        wrote on last edited by
        #3

        Easy..//lv_DtSet is dataset containing data.. if (lv_DtSet.Tables[0].Rows.Count > 0) { foreach (DataRow lv_Row in lv_DtSet.Tables[0].Rows) { if (!Convert.IsDBNull(lv_Row["ColumnName"])) String ColumnData = (String)lv_Row["ColumnName"]; //Alternately u can use Column index also. } }


        "If our Mind can, the Program can !!" ≡ ░Ŗǿђầŋ٭ ≡

        S 1 Reply Last reply
        0
        • T theScorp

          Easy..//lv_DtSet is dataset containing data.. if (lv_DtSet.Tables[0].Rows.Count > 0) { foreach (DataRow lv_Row in lv_DtSet.Tables[0].Rows) { if (!Convert.IsDBNull(lv_Row["ColumnName"])) String ColumnData = (String)lv_Row["ColumnName"]; //Alternately u can use Column index also. } }


          "If our Mind can, the Program can !!" ≡ ░Ŗǿђầŋ٭ ≡

          S Offline
          S Offline
          Sonia Gupta
          wrote on last edited by
          #4

          What is the difference in using the column index and the column name? which one is advantageous? -- modified at 2:11 Monday 14th May, 2007

          T 1 Reply Last reply
          0
          • S somchoto

            How to get data in column from dataset? i have data in dataset and i want data from some column in dataset.

            S Offline
            S Offline
            somchoto
            wrote on last edited by
            #5

            Use VB.NET

            T 1 Reply Last reply
            0
            • S Sonia Gupta

              What is the difference in using the column index and the column name? which one is advantageous? -- modified at 2:11 Monday 14th May, 2007

              T Offline
              T Offline
              theScorp
              wrote on last edited by
              #6

              Both have their own importance. Lets consider an example Suppose you are getting data from Database using a Stored procedure. Stored procedure contains Select as.. Select ID, Name, Value from Table1 When you will use this DB procedure in the C#.. You have 2 options Either to get by Column name or by Index.. long id; String Name, Value; // using Index id = (long) lv_DtSet.Tables[0].Rows[0][0]; Name = (String) lv_DtSet.Tables[0].Rows[0][1]; Value = (String) lv_DtSet.Tables[0].Rows[0][2]; //using Column Name id = (long) lv_DtSet.Tables[0].Rows[0]["ID"]; Name = (String) lv_DtSet.Tables[0].Rows[0]["Name"]; Value = (String) lv_DtSet.Tables[0].Rows[0]["Value"]; Now, if you look at Index case you don't know which value u r retrieving. So, if someday DB person changes sequence of columns say.. Select ID, Value, Name from Table1 you r in trouble. B'coz no exception will be raised.. bt Name and Value will get interchanged. So I will prefer to use Column name in this case. B'coz Changing of column name in DB is less likely. And eventhough the Sequence of columns in Select query gets changed, u don't have to change your code. But there are some times.. u don't know column names OR u want to read data serially Column1, column2 etc.. then use Column indexes. Depends on situation. But I will prefer to use Column name as far as possible. And by the way its.. ROHAN :)


              "If our Mind can, the Program can !!" ≡ ░Ŗổђầŋ٭ ≡

              S 1 Reply Last reply
              0
              • T theScorp

                Both have their own importance. Lets consider an example Suppose you are getting data from Database using a Stored procedure. Stored procedure contains Select as.. Select ID, Name, Value from Table1 When you will use this DB procedure in the C#.. You have 2 options Either to get by Column name or by Index.. long id; String Name, Value; // using Index id = (long) lv_DtSet.Tables[0].Rows[0][0]; Name = (String) lv_DtSet.Tables[0].Rows[0][1]; Value = (String) lv_DtSet.Tables[0].Rows[0][2]; //using Column Name id = (long) lv_DtSet.Tables[0].Rows[0]["ID"]; Name = (String) lv_DtSet.Tables[0].Rows[0]["Name"]; Value = (String) lv_DtSet.Tables[0].Rows[0]["Value"]; Now, if you look at Index case you don't know which value u r retrieving. So, if someday DB person changes sequence of columns say.. Select ID, Value, Name from Table1 you r in trouble. B'coz no exception will be raised.. bt Name and Value will get interchanged. So I will prefer to use Column name in this case. B'coz Changing of column name in DB is less likely. And eventhough the Sequence of columns in Select query gets changed, u don't have to change your code. But there are some times.. u don't know column names OR u want to read data serially Column1, column2 etc.. then use Column indexes. Depends on situation. But I will prefer to use Column name as far as possible. And by the way its.. ROHAN :)


                "If our Mind can, the Program can !!" ≡ ░Ŗổђầŋ٭ ≡

                S Offline
                S Offline
                Sonia Gupta
                wrote on last edited by
                #7

                Is there any difference in the speed that who will get u the records quickly???????

                T 1 Reply Last reply
                0
                • S somchoto

                  Use VB.NET

                  T Offline
                  T Offline
                  theScorp
                  wrote on last edited by
                  #8

                  This[^] will convert it for u.


                  "If our Mind can, the Program can !!" ≡ ░Ŗổђầŋ٭ ≡

                  1 Reply Last reply
                  0
                  • S Sonia Gupta

                    Is there any difference in the speed that who will get u the records quickly???????

                    T Offline
                    T Offline
                    theScorp
                    wrote on last edited by
                    #9

                    As long as i know there is no difference in speed while retrieving data.


                    "If our Mind can, the Program can !!" ≡ ░Ŗổђầŋ٭ ≡

                    1 Reply Last reply
                    0
                    • S somchoto

                      How to get data in column from dataset? i have data in dataset and i want data from some column in dataset.

                      S Offline
                      S Offline
                      somchoto
                      wrote on last edited by
                      #10

                      Thank you

                      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