dt.reset() destroys independent datarow in memory

D

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
 
C

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top