Home All Groups Group Topic Archive Search About

dt.reset() destroys independent datarow in memory

Author
16 May 2006 5:21 PM
Dean Slindee
I have noticed that doing a datatable.reset() wipes out an "independently"
declared datarow copied from a single datatable row.  What is curious is
that if a dataset is substituted for the datatable, the "independently"
declared datarow is not destroyed.  Is this difference in operation of
datatable vs. dataset by design or a Microsoft error?


   Private drOriginal As DataRow 'independently declared datarow within same
form


Form paint function, where drOriginal is loaded:

   Public Sub FormPaint(ByVal intActivityID As Integer)

      Dim dt As New DataTable

      Dim dr As DataRow

      dt = dal.GetUserActivityRowWithActivityID(intActivityID) 'returns 1
row

      For Each dr In dt.Rows

         drOriginal = dr

      Next

      dt.Reset()


      'subsequent processing reusing dt is not shown


      dt = Nothing

   End Sub


When a subsequent event needs to use drOriginal, drOriginal is empty (a
result of dt.Reset())

Again, if a dataset had been used instead of the datatable, drOriginal would
be subsequently intact.



Thanks,

Dean Slindee

Author
16 May 2006 6:03 PM
Cor Ligthert [MVP]
Dean,

Dt.clear and DS.clear are for me as well not the most sure commands.

I do mostly ds = new dataset to clear a dataset.
dt = new datatable

Cor

Show quoteHide quote
"Dean Slindee" <slin***@charter.net> schreef in bericht
news:kZnag.34$hD5.32@fe04.lga...
>I have noticed that doing a datatable.reset() wipes out an "independently"
>declared datarow copied from a single datatable row.  What is curious is
>that if a dataset is substituted for the datatable, the "independently"
>declared datarow is not destroyed.  Is this difference in operation of
>datatable vs. dataset by design or a Microsoft error?
>
>
>   Private drOriginal As DataRow 'independently declared datarow within
> same form
>
>
> Form paint function, where drOriginal is loaded:
>
>   Public Sub FormPaint(ByVal intActivityID As Integer)
>
>      Dim dt As New DataTable
>
>      Dim dr As DataRow
>
>      dt = dal.GetUserActivityRowWithActivityID(intActivityID) 'returns 1
> row
>
>      For Each dr In dt.Rows
>
>         drOriginal = dr
>
>      Next
>
>      dt.Reset()
>
>
>      'subsequent processing reusing dt is not shown
>
>
>      dt = Nothing
>
>   End Sub
>
>
> When a subsequent event needs to use drOriginal, drOriginal is empty (a
> result of dt.Reset())
>
> Again, if a dataset had been used instead of the datatable, drOriginal
> would be subsequently intact.
>
>
>
> Thanks,
>
> Dean Slindee
>
>
>
>
>
>