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 do I ...

How do I ...

Scheduled Pinned Locked Moved C#
questioncsharpdatabase
5 Posts 4 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.
  • B Offline
    B Offline
    BillAnton
    wrote on last edited by
    #1

    Hello to all, I have an Access table with several rows in it and a boolean field (column) that only has one row (record) that is TRUE. Using C# how do I programmatically determine the row that is TRUE and get the index of that row? So far I am at: foreach (DataRow row in ds.Tables["currlist"].Rows I would assume this will go through each row and then find the row that is TRUE in the boolean field. If there is a different, better way please point me in the right direction. Thanks, BIll Antonacchio

    F R G 3 Replies Last reply
    0
    • B BillAnton

      Hello to all, I have an Access table with several rows in it and a boolean field (column) that only has one row (record) that is TRUE. Using C# how do I programmatically determine the row that is TRUE and get the index of that row? So far I am at: foreach (DataRow row in ds.Tables["currlist"].Rows I would assume this will go through each row and then find the row that is TRUE in the boolean field. If there is a different, better way please point me in the right direction. Thanks, BIll Antonacchio

      F Offline
      F Offline
      Frank Lepkowski
      wrote on last edited by
      #2

      Using a DataColumn might be quicker since you are searching for a particular value for only one attribute of the table, not sure though.

      1 Reply Last reply
      0
      • B BillAnton

        Hello to all, I have an Access table with several rows in it and a boolean field (column) that only has one row (record) that is TRUE. Using C# how do I programmatically determine the row that is TRUE and get the index of that row? So far I am at: foreach (DataRow row in ds.Tables["currlist"].Rows I would assume this will go through each row and then find the row that is TRUE in the boolean field. If there is a different, better way please point me in the right direction. Thanks, BIll Antonacchio

        R Offline
        R Offline
        Ryan Roberts
        wrote on last edited by
        #3

        Try ds.Tables["currlist"].Select("whatyourfieldiscalled='true'"); Will return a DataRow, a much nicer way than using a linear search. Ryan

        B 1 Reply Last reply
        0
        • R Ryan Roberts

          Try ds.Tables["currlist"].Select("whatyourfieldiscalled='true'"); Will return a DataRow, a much nicer way than using a linear search. Ryan

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

          Hi Ryan, Thank you kindly for that. Will try to get this to give me the info needed. I need to rethink the question though. Will this give me the row number that contains the TRUE field? What I need to get is the index number of the row that contains the TRUE field. Regards, Bill Antonacchio

          1 Reply Last reply
          0
          • B BillAnton

            Hello to all, I have an Access table with several rows in it and a boolean field (column) that only has one row (record) that is TRUE. Using C# how do I programmatically determine the row that is TRUE and get the index of that row? So far I am at: foreach (DataRow row in ds.Tables["currlist"].Rows I would assume this will go through each row and then find the row that is TRUE in the boolean field. If there is a different, better way please point me in the right direction. Thanks, BIll Antonacchio

            G Offline
            G Offline
            Grimolfr
            wrote on last edited by
            #5

            ** same answer **


            Grim

            (aka Toby)

            MCDBA, MCSD, MCP+SB

            Need a Second Life?

            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