locked
Data in sql read is not getting refreshed. RRS feed

  • Question

  • User-244779555 posted

    I am running the code below to read a sql table and populate the values into a list.

    This works on the first run through, but after the data has been processed, and the process then re runs, if the sql table has been modified externally, the read of the records does not change. I imagine it is being cached somwhere but as I re dim the dData variable, shouldn't it all be dropped and run afresh?

     

     Dim dData
            'make sure that the list is empty
            Ticketlist.Clear()
      'Select the table to extract the data from and create the SQL

                dData = From i In DB.DLT_Log _
                            Where i.cleared_date Is Nothing And i.update_date IsNot Nothing And i.Comment Is Nothing _
                            Order By i.Id _
                            Select i

            'now run the SQL and for each row add the data to the list item
            For Each dItem In dData
                Dim DataX As TicketData = New TicketData

                DataX.Id = dItem.id
                DataX.Action = dItem.action
                DataX.ClearedDate = dItem.cleared_date
                DataX.Comment = dItem.comment
                DataX.RecordDate = dItem.record_date
                DataX.CreatedBy = dItem.created_by
                DataX.CreateDate = dItem.create_date
                DataX.UpdateDate = dItem.update_date
                'add the list items to the list
                Ticketlist.Add(DataX)
            Next 

    Tuesday, February 1, 2011 5:25 AM

All replies

  • User877341716 posted

    Hi,

    You can Dispose the object after it is used so that next time a new object will be created and filled. 

    Tuesday, February 1, 2011 7:16 AM
  • User-244779555 posted

    Hi

    Dispose is not available on dData, so I set to nothing, and then re ran from the dDate= from ..................etcetc

    But it refilled it with the original data rather than the db table's data ???

     

    Tuesday, February 1, 2011 7:55 AM