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. Filtering a typed datatable problem

Filtering a typed datatable problem

Scheduled Pinned Locked Moved C#
helpdatabasesql-serversysadmin
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.
  • B Offline
    B Offline
    blakey404
    wrote on last edited by
    #1

    Hello, I have a strange problem using typed datasets. I have the following datatable in a typed dataset ChainDetail ----------- ChainID Code Description I've populated an instance of the datatable with 2 rows loaded from SQL server. Here's my problem... When I either use DataTable.Select or create a DataView and apply a filter to retrieve one row, the select/filter work fine however the datarow returned has FOUR columns. [0] contains ChainID [1] contains Code [2] contains {} [3] contains Description This means that I can't cast this to a ChainDetailDataRow, as column [2] should be Description. Any help or suggestions will be much appreciated! Thanks A Very Confused Blakey404

    R 1 Reply Last reply
    0
    • B blakey404

      Hello, I have a strange problem using typed datasets. I have the following datatable in a typed dataset ChainDetail ----------- ChainID Code Description I've populated an instance of the datatable with 2 rows loaded from SQL server. Here's my problem... When I either use DataTable.Select or create a DataView and apply a filter to retrieve one row, the select/filter work fine however the datarow returned has FOUR columns. [0] contains ChainID [1] contains Code [2] contains {} [3] contains Description This means that I can't cast this to a ChainDetailDataRow, as column [2] should be Description. Any help or suggestions will be much appreciated! Thanks A Very Confused Blakey404

      R Offline
      R Offline
      Rob Smiley
      wrote on last edited by
      #2

      Hi, how many columns are returned from the query that populates the datatable? if you're using 'SELECT * FROM...' change it to 'SELECT ChainID, Code, Description FROM...' Perhaps you could post some of the code if this hasn't helped

      "An eye for an eye only ends up making the whole world blind"

      B 2 Replies Last reply
      0
      • R Rob Smiley

        Hi, how many columns are returned from the query that populates the datatable? if you're using 'SELECT * FROM...' change it to 'SELECT ChainID, Code, Description FROM...' Perhaps you could post some of the code if this hasn't helped

        "An eye for an eye only ends up making the whole world blind"

        B Offline
        B Offline
        blakey404
        wrote on last edited by
        #3

        This is the strangest thing... That is exacly what my query looks like, its in a stored procedure. When i populate the datatable the three columns are there and correct... its only when i create a dataview or use .Select that the extra colum is inserted into my results!! i'm at home now but i will connect to work later on and give a code example... cheers for the reply

        1 Reply Last reply
        0
        • R Rob Smiley

          Hi, how many columns are returned from the query that populates the datatable? if you're using 'SELECT * FROM...' change it to 'SELECT ChainID, Code, Description FROM...' Perhaps you could post some of the code if this hasn't helped

          "An eye for an eye only ends up making the whole world blind"

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

          I've just had a brainwave... This datatable is populating a combobox, directly via databinding (datasource, datavalue etc) To clear the combo box i am setting it's index to -1... could this or something else related to the combobox be inserting my extra column? i bet it is. crap that's going to be fun to find.

          R 1 Reply Last reply
          0
          • B blakey404

            I've just had a brainwave... This datatable is populating a combobox, directly via databinding (datasource, datavalue etc) To clear the combo box i am setting it's index to -1... could this or something else related to the combobox be inserting my extra column? i bet it is. crap that's going to be fun to find.

            R Offline
            R Offline
            Rob Smiley
            wrote on last edited by
            #5

            The databinding shouldn't be the problem here as that's very much a read-only action... then again, I've had all sorts of problems with the comboBox and datasource properties! Try removing the selection using .SelectedItem = null instead. Can you step through the code and find the point where the extra column is added? Good luck! Rob

            "An eye for an eye only ends up making the whole world blind"

            B 1 Reply Last reply
            0
            • R Rob Smiley

              The databinding shouldn't be the problem here as that's very much a read-only action... then again, I've had all sorts of problems with the comboBox and datasource properties! Try removing the selection using .SelectedItem = null instead. Can you step through the code and find the point where the extra column is added? Good luck! Rob

              "An eye for an eye only ends up making the whole world blind"

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

              Here's one for anyone to look out for in the future (i feel like an idiot) the Description Column should really have been the "Name" column therefore when i loaded the results into the dataset the name column was blank and the description colum was created thanks for your help! A very tired but enlightened Blakey404

              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