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. DataSet, DataRows etc.

DataSet, DataRows etc.

Scheduled Pinned Locked Moved C#
helpdatabasequestion
5 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.
  • D Offline
    D Offline
    deanoA
    wrote on last edited by
    #1

    Hi! I'm trying to print the values in my DataSet. It has a single row in it. I used this CommandText: "Select NAME from Authors" Now the query returns all the names. Now, I want to print the values in the dataset and I want to use foreach because I do not know how many names I might get. But the problem is, what do I use to traverse my set? I used this ff code but it generates an error: DataRow dr = dsDBData.Tables[0].Rows[0]; foreach (DataColumn dc in dr) { MessageBox.Show(dc.ToString()); } Please help. "To teach is to learn twice"

    M A 2 Replies Last reply
    0
    • D deanoA

      Hi! I'm trying to print the values in my DataSet. It has a single row in it. I used this CommandText: "Select NAME from Authors" Now the query returns all the names. Now, I want to print the values in the dataset and I want to use foreach because I do not know how many names I might get. But the problem is, what do I use to traverse my set? I used this ff code but it generates an error: DataRow dr = dsDBData.Tables[0].Rows[0]; foreach (DataColumn dc in dr) { MessageBox.Show(dc.ToString()); } Please help. "To teach is to learn twice"

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      daljv wrote: foreach (DataColumn dc in dr) Change it to something like this:

      foreach(DataColumn in dr.Table.Columns)

      Mazy No sig. available now.

      1 Reply Last reply
      0
      • D deanoA

        Hi! I'm trying to print the values in my DataSet. It has a single row in it. I used this CommandText: "Select NAME from Authors" Now the query returns all the names. Now, I want to print the values in the dataset and I want to use foreach because I do not know how many names I might get. But the problem is, what do I use to traverse my set? I used this ff code but it generates an error: DataRow dr = dsDBData.Tables[0].Rows[0]; foreach (DataColumn dc in dr) { MessageBox.Show(dc.ToString()); } Please help. "To teach is to learn twice"

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

        You have more than one row and DataRow object doesn't contain Columns objects. See help on Data namespace. Should be: foreach(DataRow dr in dsDBData.Tables[0].Rows) { MessageBox.Show(dr[0].ToString()); } Hi, AW

        M 1 Reply Last reply
        0
        • A A Wegierski

          You have more than one row and DataRow object doesn't contain Columns objects. See help on Data namespace. Should be: foreach(DataRow dr in dsDBData.Tables[0].Rows) { MessageBox.Show(dr[0].ToString()); } Hi, AW

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          A.Wegierski wrote: DataRow object doesn't contain Columns objects DataRow.Table.Columns Mazy No sig. available now.

          A 1 Reply Last reply
          0
          • M Mazdak

            A.Wegierski wrote: DataRow object doesn't contain Columns objects DataRow.Table.Columns Mazy No sig. available now.

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

            :laugh:Thx Hi, AW

            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