Results 1 to 1 of 1

Thread: Clearing column in a DataSet - is this a hack?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518

    Clearing column in a DataSet - is this a hack?

    I have a dataset that I'm working with that will sit in memory for as long as the user has the program running. Let's say there's a column in this dataset whose values will change as the user works, and at some point the user decides to restart everything. The way I am currently resetting the particular column in the dataset is:

    dsDataSet.Tables("TableName").Columns.Remove("ColumnName")

    ...and then re-adding the column (default values are OK for my purposes). Is this the "right" way to clear a table column in a dataset or is there a better/more accepted way? While there's a .Clear method for tables, there isn't one for columns.

    Hmm, maybe this is "cleaner":
    Code:
            Dim objSelectedRows() As DataRow
            objSelectedRows = dsDataSet.Tables("TableName").Select("Value <> 0")
            For Each objRow In objSelectedRows
                objRow("Value") = 0
            Next
    Last edited by Slow_Learner; Sep 24th, 2002 at 05:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width