DataRow problem please help

  • Thread starter Thread starter smtwtfs007
  • Start date Start date
S

smtwtfs007

Guys,

I have declared 2 dataRows and assigned New daraRows as below.

Dim aRow as DataRow
aRow = OutFormat.DataSet.Tables("demotbl").NewRow '*** Point 1

----
----

Dim bRow as DataRow
bRow = OutFormat.DataSet.Tables("demotbl").NewRow '***Point 2

---
---

bRow = OutFormat.DataSet.Tables("demotbl").NewRow 'No. '*** Point 3

---
---

Point 1: I have created aRow and assigned some fields to its columns.
Point 2:Then I created bRow and assigned some fields (In the debug
mode I can see aRow is still active).
Point 3:Then I created again bRow and this time It has erased all the
contents of aRow.

How would that possible? I have not changed anything aRow.

Please help.
 
smtwtfs007,

You are leaving out too much of your code for anybody to provide much help.

However, remember that getting a new row from the datatable's NewRow method
does not add the row to the datatable.

After getting a new row and filling its columns with data, you must call the
datatable's Rows' Add method to add the row to the datatable.

Kerry Moorman
 
Not positive, but I believe aRow and bRow are the particular rows of your
DataSet.

If you want to work with *copies* of your DataSet, try something like:

aRow = new DataRow(OutFormat.DataSet.Tables("demotbl").NewRow

*** Not sure about the syntax / untested! ***

I bet whenever you assign something to another row like you are doing below,
you could be telling the DataSet to copy that row to the last row.

Hope this helps!
 
Back
Top