Adding line number to a dataset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devquest
    New Member
    • Dec 2009
    • 12

    Adding line number to a dataset

    I have a dataset that is being populated from a text file.
    example:
    OrderNumber,Nam e,Model,Cost
    123,john doe,product1,20 .99
    123,john doe,product2,10 .75

    There can be multiple of the same order number. In the dataset, I want to have a column "line number" and I want to put in it the value of the linenumber (in this case 1 and 2) per order. In sql , I was able to accomplish this by inserting rownumber() and grouping by order number. Can this be done in .net?
    Thank you.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    A DataSet contains one or more DataTable objects.

    When you fill a DataSet you are populating the tables within it with data.

    I'm not sure what you are trying to do here...but I think what you are looking to do is add a column to the DataTable within the DataSet that has been populated with the information in the text file.

    Once you've populated the DataTable, you could try adding a "lineNumber " column to the DataTable using the DataTable.Colum ns property....

    Once you've done that you'll have to loop through all of the Rows in the DataTable and add the line number value to the "lineNumber " column.

    -Frinny

    Comment

    Working...