By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Original Rows

P: n/a
My Brain is dead !!!!!

I modify a single row in a DataTable By setting the FirstName column in a
specific row to another name. ( Without Accepting Changes ).

However, this statement still returns the rows with the 'New Value in it'
shouldnt it be the values before I made the change or have I missed
something.

r = Ds1.Tables(0).Select(Nothing, Nothing, DataViewRowState.OriginalRows)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
Nov 20 '05 #1
Share this Question
Share on Google+
31 Replies


P: n/a
Hi Terry,

You know this page?

http://msdn.microsoft.com/library/de...ClassTopic.asp

Cor
Nov 20 '05 #2

P: n/a
Yes, I'm aware of this page, however, this refers to a different method
which uses a DataView class to filter the output.

When using the .Select method of a DataTable, this appears to give strange
results.

Try it and let me know.,

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi Terry,

You know this page?

http://msdn.microsoft.com/library/de...ClassTopic.asp
Cor

Nov 20 '05 #3

P: n/a
The select method seems to have a bug in it, however, using the
StateFiltering of the devault view, this works no problem.

Ds1.Tables(0).DefaultView.RowStateFilter = CType(ComboBox1.SelectedItem,
State).MyState

Dim i As Integer

For i = 0 To Ds1.Tables(0).DefaultView.Count - 1

txtConsole.AppendText(Ds1.Tables(0).DefaultView.It em(i)("FirstName") &
(Microsoft.VisualBasic.vbCrLf))

Next
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Yes, I'm aware of this page, however, this refers to a different method
which uses a DataView class to filter the output.

When using the .Select method of a DataTable, this appears to give strange
results.

Try it and let me know.,

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi Terry,

You know this page?

http://msdn.microsoft.com/library/de...ClassTopic.asp

Cor


Nov 20 '05 #4

P: n/a
Hi Terry,

Did you try this?
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim r() As DataRow = mytable.Select(Nothing,Nothing,myview.RowStateFilt er)

I hope that your brain will come again alive with this?

:-)

Cor
Nov 20 '05 #5

P: n/a
No thats doesent work. It appears that the select method does not work
properly. So I just have to do it the way I already said.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

Did you try this?
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim r() As DataRow = mytable.Select(Nothing,Nothing,myview.RowStateFilt er)

I hope that your brain will come again alive with this?

:-)

Cor

Nov 20 '05 #6

P: n/a
Do you use VBNet?
No thats doesent work. It appears that the select method does not work
properly. So I just have to do it the way I already said.

I tested it completly and it did work, there is one strange thing, try this
one.

Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
Dim myView As New DataView(myTable)
myTable.Rows(1)(0) = "Terry"
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module

In this test when you do not do the Reject Changes it cannot get the deleted
information.

However the part that you showed did work perfectly for me.

Cor
Nov 20 '05 #7

P: n/a
Do you use VBNet?
No thats doesent work. It appears that the select method does not work
properly. So I just have to do it the way I already said.

I tested it completly and it did work, there is one strange thing, try this
one.

Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
Dim myView As New DataView(myTable)
myTable.Rows(1)(0) = "Terry"
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module

In this test when you do not do the Reject Changes it cannot get the deleted
information.

However the part that you showed did work perfectly for me.

Cor
Nov 20 '05 #8

P: n/a
Actually, it is not working, this snippit Displays, 'Terry' then 'Cor 1' The
RowState Filter is set to origional rows and so neither of these should have
appeared this way as the second was deleted.

If this is what you see then it confirms my suspicions.


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
Do you use VBNet?
No thats doesent work. It appears that the select method does not work
properly. So I just have to do it the way I already said.
I tested it completly and it did work, there is one strange thing, try

this one.

Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
Dim myView As New DataView(myTable)
myTable.Rows(1)(0) = "Terry"
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module

In this test when you do not do the Reject Changes it cannot get the deleted information.

However the part that you showed did work perfectly for me.

Cor

Nov 20 '05 #9

P: n/a
Actually, it is not working, this snippit Displays, 'Terry' then 'Cor 1' The
RowState Filter is set to origional rows and so neither of these should have
appeared this way as the second was deleted.

If this is what you see then it confirms my suspicions.


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
Do you use VBNet?
No thats doesent work. It appears that the select method does not work
properly. So I just have to do it the way I already said.
I tested it completly and it did work, there is one strange thing, try

this one.

Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
Dim myView As New DataView(myTable)
myTable.Rows(1)(0) = "Terry"
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module

In this test when you do not do the Reject Changes it cannot get the deleted information.

However the part that you showed did work perfectly for me.

Cor

Nov 20 '05 #10

P: n/a
Hi Terry,

I get the idea that you interpret the code not right and want something
else, hoewever it is correct, see my comment inline.

myTable.Rows(1)(0) = "Terry"
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)

In my opinion should this sentence give the currentrows from the table which
had in the originalrowstate "Cor1" in myColumn" from those contains row 1
now "Terry".

And it works completly correct.

Maybe you want something else, however this is what in my opinion is written
in the sentences above.

Cor
Nov 20 '05 #11

P: n/a
Ah yes, but you are using a new view, not the default view of the table. If
you use that you will see a difference.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Oc**************@tk2msftngp13.phx.gbl...
Hi Terry,

I get the idea that you interpret the code not right and want something
else, hoewever it is correct, see my comment inline.

myTable.Rows(1)(0) = "Terry"
myView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing, myView.RowStateFilter)

In my opinion should this sentence give the currentrows from the table which had in the originalrowstate "Cor1" in myColumn" from those contains row 1
now "Terry".

And it works completly correct.

Maybe you want something else, however this is what in my opinion is written in the sentences above.

Cor

Nov 20 '05 #12

P: n/a
Hi Terry,

Do you mean this, that gives exactly the same resultst?

Cor

\\\
Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
myTable.Rows(1)(0) = "Terry"
myTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing,
myTable.DefaultView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, _
myTable.DefaultView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module
///
Nov 20 '05 #13

P: n/a

ADD THIS CODE TO A BUTTON
--------------------------
'create a new table
Dim MyTable As New DataTable
'create a column
MyTable.Columns.Add(New DataColumn("Data"))
'Create Rows
Dim r As DataRow
Dim i As Integer
For i = 0 To 5
r = MyTable.NewRow()
r("Data") = "Item" & i.ToString()
MyTable.Rows.Add(r)
Next
MyTable.AcceptChanges()
'Ok Lets Print out the rows unmodified
Debug.WriteLine("------- Unmodified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Now lets Modify one element at row(1)
MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified
Debug.WriteLine("------- Modified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Declare an array of rows
Dim OriginalRows() As DataRow

'Get them from the Table using select statement
OriginalRows = MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)

Debug.WriteLine("------- These 'SHOULD' be the original
ows ---------")
For Each r In OriginalRows
Debug.WriteLine(r("Data"))
Next
THIS IS THE RESULT
-------------------
------- Unmodified ---------
Item0
Item1
Item2
Item3
Item4
Item5
------- Modified ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5
------- These 'SHOULD' be the original rows ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

Do you mean this, that gives exactly the same resultst?

Cor

\\\
Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
myTable.Rows(1)(0) = "Terry"
myTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing,
myTable.DefaultView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, _
myTable.DefaultView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module
///

Nov 20 '05 #14

P: n/a
Yes this samle explicitly sets the RowState Filter of the default view,
whereas, the select statement should return a set of rows based on the
parameters passed, and if the rowstate filter has not been explicitly set
before this call, the select statement does not work. See my sample,
alongside this post.

Cheers for looking at this with me.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

Do you mean this, that gives exactly the same resultst?

Cor

\\\
Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
myTable.Rows(1)(0) = "Terry"
myTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows
Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing,
myTable.DefaultView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, _
myTable.DefaultView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module
///

Nov 20 '05 #15

P: n/a
Hi Terry,

With me it are the original rows with new values. Just as I expected.
Deleted rows are in it and added rows not.

A problem I discovered is that it goes wrong when the value is nothing
however I tried that and that is testable to Nothing however the rownumber
is there.

Cor

\\\
OriginalRows = MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)
Debug.WriteLine("------- These 'SHOULD' be the
originalows(---------")
For Each r In OriginalRows
Debug.WriteLine(r("Data"))
Next
///
Nov 20 '05 #16

P: n/a
Hi Terry,

When you add this to your sample you see better how it looks internally

Cor
\\\
Dim ds As New DataSet
ds.Tables.Add(MyTable)
Dim sw As New System.IO.StringWriter
ds.WriteXml(sw, XmlWriteMode.DiffGram)
MessageBox.Show(sw.ToString)
///
Nov 20 '05 #17

P: n/a
I have 2 go for a while, I'l come back to this later
Cheers terry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...

ADD THIS CODE TO A BUTTON
--------------------------
'create a new table
Dim MyTable As New DataTable
'create a column
MyTable.Columns.Add(New DataColumn("Data"))
'Create Rows
Dim r As DataRow
Dim i As Integer
For i = 0 To 5
r = MyTable.NewRow()
r("Data") = "Item" & i.ToString()
MyTable.Rows.Add(r)
Next
MyTable.AcceptChanges()
'Ok Lets Print out the rows unmodified
Debug.WriteLine("------- Unmodified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Now lets Modify one element at row(1)
MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified
Debug.WriteLine("------- Modified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Declare an array of rows
Dim OriginalRows() As DataRow

'Get them from the Table using select statement
OriginalRows = MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)

Debug.WriteLine("------- These 'SHOULD' be the original
ows ---------")
For Each r In OriginalRows
Debug.WriteLine(r("Data"))
Next
THIS IS THE RESULT
-------------------
------- Unmodified ---------
Item0
Item1
Item2
Item3
Item4
Item5
------- Modified ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5
------- These 'SHOULD' be the original rows ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

Do you mean this, that gives exactly the same resultst?

Cor

\\\
Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
myTable.Rows(1)(0) = "Terry"
myTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing,
myTable.DefaultView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, _
myTable.DefaultView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module
///


Nov 20 '05 #18

P: n/a
Hi,

Use a dataview for that to work the way you want.

'create a new table

Dim MyTable As New DataTable

'create a column

MyTable.Columns.Add(New DataColumn("Data"))

'Create Rows

Dim r As DataRow

Dim i As Integer

For i = 0 To 5

r = MyTable.NewRow()

r("Data") = "Item" & i.ToString()

MyTable.Rows.Add(r)

Next

MyTable.AcceptChanges()

Dim drv As DataRowView

'Ok Lets Print out the rows unmodified

Debug.WriteLine("------- Unmodified ---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Now lets Modify one element at row(1)

MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified

Debug.WriteLine("------- Modified ---------")

MyTable.DefaultView.RowStateFilter = DataViewRowState.ModifiedCurrent

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Declare an array of rows

'Get them from the Table using select statement

MyTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows

Debug.WriteLine("------- These 'SHOULD' be the original rows---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

Ken

------------------

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have 2 go for a while, I'l come back to this later
Cheers terry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message
news:uw**************@TK2MSFTNGP12.phx.gbl...

Nov 20 '05 #19

P: n/a
Hi Ken,

This gives exact the same results as I showed Terry in 5 different ways.
On one of those Terry gave this answer.
Yes, I'm aware of this page, however, this refers to a different method
which uses a DataView class to filter the output.

When using the .Select method of a DataTable, this appears to give strange
results.
I get the idea that Terry want to have with this methode the original values
and not the original rows.

Cor

"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:en**************@TK2MSFTNGP12.phx.gbl... Hi,

Use a dataview for that to work the way you want.

'create a new table

Dim MyTable As New DataTable

'create a column

MyTable.Columns.Add(New DataColumn("Data"))

'Create Rows

Dim r As DataRow

Dim i As Integer

For i = 0 To 5

r = MyTable.NewRow()

r("Data") = "Item" & i.ToString()

MyTable.Rows.Add(r)

Next

MyTable.AcceptChanges()

Dim drv As DataRowView

'Ok Lets Print out the rows unmodified

Debug.WriteLine("------- Unmodified ---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Now lets Modify one element at row(1)

MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified

Debug.WriteLine("------- Modified ---------")

MyTable.DefaultView.RowStateFilter = DataViewRowState.ModifiedCurrent

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Declare an array of rows

'Get them from the Table using select statement

MyTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows

Debug.WriteLine("------- These 'SHOULD' be the original rows---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

Ken

------------------

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
I have 2 go for a while, I'l come back to this later
Cheers terry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message
news:uw**************@TK2MSFTNGP12.phx.gbl...


Nov 20 '05 #20

P: n/a
Hi Terry,

Is this the result you want?
See the second one I first have taken the old one to show where it has to be
in the code.

\\\
Dim OriginalRows() As DataRow
'Get them from the Table using select statement
OriginalRows = MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)
Debug.WriteLine("------- These 'SHOULD' be the originalows(---------")
For Each r In OriginalRows
If Not r("Data") Is Nothing Then
Debug.WriteLine(r("Data"))
End If
Next
Dim dt2 As DataTable = MyTable.Copy
dt2.RejectChanges()
'Get them from the Table using select statement
OriginalRows = dt2.Select(Nothing, Nothing, DataViewRowState.OriginalRows)
Debug.WriteLine("------- These 'Are' the originalows(---------")
For Each r In OriginalRows
If Not r("Data") Is Nothing Then
Debug.WriteLine(r("Data"))
End If
Next
///

Cor
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> schreef in
bericht news:%2****************@tk2msftngp13.phx.gbl...
I have 2 go for a while, I'l come back to this later
Cheers terry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:uw**************@TK2MSFTNGP12.phx.gbl...

ADD THIS CODE TO A BUTTON
--------------------------
'create a new table
Dim MyTable As New DataTable
'create a column
MyTable.Columns.Add(New DataColumn("Data"))
'Create Rows
Dim r As DataRow
Dim i As Integer
For i = 0 To 5
r = MyTable.NewRow()
r("Data") = "Item" & i.ToString()
MyTable.Rows.Add(r)
Next
MyTable.AcceptChanges()
'Ok Lets Print out the rows unmodified
Debug.WriteLine("------- Unmodified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Now lets Modify one element at row(1)
MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified
Debug.WriteLine("------- Modified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Declare an array of rows
Dim OriginalRows() As DataRow

'Get them from the Table using select statement
OriginalRows = MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)

Debug.WriteLine("------- These 'SHOULD' be the original
ows ---------")
For Each r In OriginalRows
Debug.WriteLine(r("Data"))
Next
THIS IS THE RESULT
-------------------
------- Unmodified ---------
Item0
Item1
Item2
Item3
Item4
Item5
------- Modified ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5
------- These 'SHOULD' be the original rows ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

Do you mean this, that gives exactly the same resultst?

Cor

\\\
Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
myTable.Rows(1)(0) = "Terry"
myTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing,
myTable.DefaultView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, _
myTable.DefaultView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module
///



Nov 20 '05 #21

P: n/a
First Question.

1.) Has anyone 'actually' tried my code example ?, if so did you get the
same results ?

2.) If yes to 1.), then why does this not work. The select satement should
be able to generate a row set based on my criteria with a set of 'Original
Rows' IE Before modification took place.

3.) If What I have said in 2.) Is incorrect, why ?

Back Later

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ol**************@tk2msftngp13.phx.gbl...
Hi Ken,

This gives exact the same results as I showed Terry in 5 different ways.
On one of those Terry gave this answer.
Yes, I'm aware of this page, however, this refers to a different method
which uses a DataView class to filter the output.

When using the .Select method of a DataTable, this appears to give strangeresults.
I get the idea that Terry want to have with this methode the original

values and not the original rows.

Cor

"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:en**************@TK2MSFTNGP12.phx.gbl...
Hi,

Use a dataview for that to work the way you want.

'create a new table

Dim MyTable As New DataTable

'create a column

MyTable.Columns.Add(New DataColumn("Data"))

'Create Rows

Dim r As DataRow

Dim i As Integer

For i = 0 To 5

r = MyTable.NewRow()

r("Data") = "Item" & i.ToString()

MyTable.Rows.Add(r)

Next

MyTable.AcceptChanges()

Dim drv As DataRowView

'Ok Lets Print out the rows unmodified

Debug.WriteLine("------- Unmodified ---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Now lets Modify one element at row(1)

MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified

Debug.WriteLine("------- Modified ---------")

MyTable.DefaultView.RowStateFilter = DataViewRowState.ModifiedCurrent

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Declare an array of rows

'Get them from the Table using select statement

MyTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows

Debug.WriteLine("------- These 'SHOULD' be the original rows---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

Ken

------------------

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:%2****************@tk2msftngp13.phx.gbl...
I have 2 go for a while, I'l come back to this later
Cheers terry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message
news:uw**************@TK2MSFTNGP12.phx.gbl...



Nov 20 '05 #22

P: n/a
First Question.

1.) Has anyone 'actually' tried my code example ?, if so did you get the
same results ?

2.) If yes to 1.), then why does this not work. The select satement should
be able to generate a row set based on my criteria with a set of 'Original
Rows' IE Before modification took place.

3.) If What I have said in 2.) Is incorrect, why ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
Hi,

Use a dataview for that to work the way you want.

'create a new table

Dim MyTable As New DataTable

'create a column

MyTable.Columns.Add(New DataColumn("Data"))

'Create Rows

Dim r As DataRow

Dim i As Integer

For i = 0 To 5

r = MyTable.NewRow()

r("Data") = "Item" & i.ToString()

MyTable.Rows.Add(r)

Next

MyTable.AcceptChanges()

Dim drv As DataRowView

'Ok Lets Print out the rows unmodified

Debug.WriteLine("------- Unmodified ---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Now lets Modify one element at row(1)

MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified

Debug.WriteLine("------- Modified ---------")

MyTable.DefaultView.RowStateFilter = DataViewRowState.ModifiedCurrent

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Declare an array of rows

'Get them from the Table using select statement

MyTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows

Debug.WriteLine("------- These 'SHOULD' be the original rows---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

Ken

------------------

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
I have 2 go for a while, I'l come back to this later
Cheers terry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message
news:uw**************@TK2MSFTNGP12.phx.gbl...


Nov 20 '05 #23

P: n/a
The original rows contain the original values. Remember that the DataTable
maintains several versions of the same row during modification before
AcceptChanges is called.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ol**************@tk2msftngp13.phx.gbl...
Hi Ken,

This gives exact the same results as I showed Terry in 5 different ways.
On one of those Terry gave this answer.
Yes, I'm aware of this page, however, this refers to a different method
which uses a DataView class to filter the output.

When using the .Select method of a DataTable, this appears to give strangeresults.
I get the idea that Terry want to have with this methode the original

values and not the original rows.

Cor

"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:en**************@TK2MSFTNGP12.phx.gbl...
Hi,

Use a dataview for that to work the way you want.

'create a new table

Dim MyTable As New DataTable

'create a column

MyTable.Columns.Add(New DataColumn("Data"))

'Create Rows

Dim r As DataRow

Dim i As Integer

For i = 0 To 5

r = MyTable.NewRow()

r("Data") = "Item" & i.ToString()

MyTable.Rows.Add(r)

Next

MyTable.AcceptChanges()

Dim drv As DataRowView

'Ok Lets Print out the rows unmodified

Debug.WriteLine("------- Unmodified ---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Now lets Modify one element at row(1)

MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified

Debug.WriteLine("------- Modified ---------")

MyTable.DefaultView.RowStateFilter = DataViewRowState.ModifiedCurrent

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

'Declare an array of rows

'Get them from the Table using select statement

MyTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows

Debug.WriteLine("------- These 'SHOULD' be the original rows---------")

For Each drv In MyTable.DefaultView

Debug.WriteLine(drv("Data"))

Next

Ken

------------------

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:%2****************@tk2msftngp13.phx.gbl...
I have 2 go for a while, I'l come back to this later
Cheers terry

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message
news:uw**************@TK2MSFTNGP12.phx.gbl...



Nov 20 '05 #24

P: n/a
Hi Terry,

I tried all your code, even changed it so that should show you, however did
you tried yourt code I changed?

You persist in my opinion with the fact that an original row needs also to
have the original values and did not give any reason why?

That is not as I try to show you in the 10 different samples I sended you,
some changed from yours. When you had looked at the latest it should all
became clear.

Cor
Nov 20 '05 #25

P: n/a
Hi Cor,
You persist in my opinion with the fact that an original row needs also to
have the original values and did not give any reason why? It does - the XML in the table proves it.

<diffgr:before>
<tblUsers diffgr:id="tblUsers1" msdata:rowOrder="0"
xmlns="http://www.tempuri.org/DS.xsd">
<UserID>1</UserID>
<FirstName>Emma</FirstName>
<LastName>Laity</LastName>
<Address>99 Highfield Road</Address>
<City>Arnam</City>
<State>Berkshire</State>
<ZIP>1DNT KNO</ZIP>
<Phone_x0020_Number>555 868333</Phone_x0020_Number>
</tblUsers>
</diffgr:before>

Yes, in fact the XML clearly shows that the table contains both versions of
the value for this row once modified. It has the 'before' attribute for the
original.

Below is the code I used to prove.

Private Sub btnShowRowState_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnShowRowState.Click

txtConsole.Text = Nothing
txtConsole.Text = ComboBox1.Text & vbCrLf & "--------------" &
vbCrLf
Dim r() As DataRow
Dim ir As DataRow

Ds1.Tables(0).DefaultView.RowStateFilter =
CType(ComboBox1.SelectedItem, State).MyState

r = Ds1.Tables(0).Select(Nothing, Nothing,
Ds1.Tables(0).DefaultView.RowStateFilter)

' METHOD 1 - Does Not Work
'For Each ir In r
'txtConsole.AppendText(ir("FirstName") &
(Microsoft.VisualBasic.vbCrLf))
'Next

'METHOD 2 - DOES work
Dim i As Integer
For i = 0 To Ds1.Tables(0).DefaultView.Count - 1

txtConsole.AppendText(Ds1.Tables(0).DefaultView.It em(i)("FirstName") &
(Microsoft.VisualBasic.vbCrLf))
Next
End Sub
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OF**************@TK2MSFTNGP11.phx.gbl... Hi Terry,

I tried all your code, even changed it so that should show you, however did you tried yourt code I changed?

You persist in my opinion with the fact that an original row needs also to
have the original values and did not give any reason why?

That is not as I try to show you in the 10 different samples I sended you,
some changed from yours. When you had looked at the latest it should all
became clear.

Cor

Nov 20 '05 #26

P: n/a
Hi Terry,
You persist in my opinion with the fact that an original row needs also to have the original values and did not give any reason why?

It does - the XML in the table proves it.

It has and to get that you can use my latest sample I have sand yesterday.

(I showed you yesterday as well that serialize method to show you that it
has the old values however not in the original row.)

Cor
Nov 20 '05 #27

P: n/a
Cor,

I can get to it using my own methods as well as yours, you seem to be
missing the point here.

*The Point*
-------------
The Select method does 'not' return the original rows 'Which we have proved
are there' using the RowState Filter in the select statement.


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Terry,
You persist in my opinion with the fact that an original row needs
also
to have the original values and did not give any reason why?

It does - the XML in the table proves it.

It has and to get that you can use my latest sample I have sand yesterday.

(I showed you yesterday as well that serialize method to show you that it
has the old values however not in the original row.)

Cor

Nov 20 '05 #28

P: n/a
Hi Terry,

The question is for me, is *selecting* the rows from the tables, selecting
the rows with the latest values using the rowstatusfilter to select or is it
selecting the rows with the originalvalues.

I stay with the first because I only use the rowstatefilter as a filter to
select the rows.

When you use the dataview it gets a different behaviour because than it is
not only filtering however as well giving the originalrows, and that for my
much more strange to see.

However which one is right, you go probably for the last, I for the first.

I hope you see my point now?

Cor
Nov 20 '05 #29

P: n/a
I think the Table.Select() method only deals with current rows. However, it
does seem to be able to distinguish, added rows etc, just not row versions,
it does not in fact support the full range of RowState enumerations.

However, when one Iterates through the Rows() Collection of the DefaultView,
the RowState Filter does report correctly. I still feel that the Select()
Method falls short of what it should be able to do, and at the least, this
should be documented as a limitation.

I think we understand each other , just coming from different angles. One
thing is that through this excercise I have learnt a little more that,
cannot be a bad thing

Thanks for taking the time out to discuss.
:)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

The question is for me, is *selecting* the rows from the tables, selecting
the rows with the latest values using the rowstatusfilter to select or is it selecting the rows with the originalvalues.

I stay with the first because I only use the rowstatefilter as a filter to
select the rows.

When you use the dataview it gets a different behaviour because than it is
not only filtering however as well giving the originalrows, and that for my much more strange to see.

However which one is right, you go probably for the last, I for the first.

I hope you see my point now?

Cor

Nov 20 '05 #30

P: n/a
OHM,
Don't confuse selecting the row with selecting the values of the row. :-)

Remember that each ROW has multiple values associated with it. So the Select
statement is returning all the rows that are "Original Rows", your for each
then is selecting the Current Values of those rows, as the default for
DataRow.Item is current value!

Also remember that the DataView returns DataRowView objects, that the
default for the DataRowView.Item property is the row state for the view.

Try the following code:

Dim view As New DataView(MyTable, Nothing, Nothing,
DataViewRowState.OriginalRows)
For Each row As DataRowView In view
Debug.WriteLine(row("Data"), "DataRowView")
Debug.WriteLine(row.Row("Data"), "DataRow")
Next

added to your code posted earlier (later?):

'create a new table
Dim MyTable As New DataTable
'create a column
MyTable.Columns.Add(New DataColumn("Data"))
'Create Rows
Dim r As DataRow
Dim i As Integer
For i = 0 To 5
r = MyTable.NewRow()
r("Data") = "Item" & i.ToString()
MyTable.Rows.Add(r)
Next
MyTable.AcceptChanges()
'Ok Lets Print out the rows unmodified
Debug.WriteLine("------- Unmodified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Now lets Modify one element at row(1)
MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified
Debug.WriteLine("------- Modified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Declare an array of rows
Dim OriginalRows() As DataRow

'Get them from the Table using select statement
OriginalRows = MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)

Debug.WriteLine("------- These 'SHOULD' be the original
ows ---------")
For Each r In OriginalRows
Debug.WriteLine(r("Data"))
Next

Debug.WriteLine("------- Display the View value & the Row
value ---------")
Dim view As New DataView(MyTable, Nothing, Nothing,
DataViewRowState.OriginalRows)
For Each row As DataRowView In view
Debug.WriteLine(row("Data"), "DataRowView")
Debug.WriteLine(row.Row("Data"), "DataRow")
Next
------- Unmodified ---------
Item0
Item1
Item2
Item3
Item4
Item5
------- Modified ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5
------- These 'SHOULD' be the original rows ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5
------- Display the View value & the Row value ---------
DataRowView: Item0
DataRow: Item0
DataRowView: Item1
DataRow: Terry Burns
DataRowView: Item2
DataRow: Item2
DataRowView: Item3
DataRow: Item3
DataRowView: Item4
DataRow: Item4
DataRowView: Item5
DataRow: Item5

Notice that the DataRow itself returns "Terry Burns", while the DataRowView
itself return "Item1".

To get the DataTable.Select to work, try the following:
Debug.WriteLine("------- These 'ARE' be the original
Values ---------")
For Each r In OriginalRows
Debug.WriteLine(r("Data", DataRowVersion.Original))
Next
If that made any sense. ;-)

Hope this helps
Jay

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:Og****************@TK2MSFTNGP12.phx.gbl...
My Brain is dead !!!!!

I modify a single row in a DataTable By setting the FirstName column in a
specific row to another name. ( Without Accepting Changes ).

However, this statement still returns the rows with the 'New Value in it'
shouldnt it be the values before I made the change or have I missed
something.

r = Ds1.Tables(0).Select(Nothing, Nothing, DataViewRowState.OriginalRows)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

Nov 20 '05 #31

P: n/a
Terry,
Reading my other post I'm not sure how clear it is. ;-)

I tried your code below, your "problem" is the believe DataTable.Select
returns different DataRow objects based on the DataViewRowState parameter,
it does not.

My understanding is: There is only a single DataRow object for each row in a
DataTable, this single DataRow object, has multiple versions of the values.
Your code reinforces my believe.

So the code:
Debug.WriteLine("------- These 'SHOULD' be the original
ows ---------")
For Each r In MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)
Debug.WriteLine(r("Data"))
Next
Returns all the DataRows that have Original Values in them, and then prints
the Current Values.

You need:
For Each r In MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows) Debug.WriteLine(r("Data", DataRowVersion.Original)) Next
Which returns all the DataRows that have Original values in them, and then
prints the Original values.

Hope this helps
Jay

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...
ADD THIS CODE TO A BUTTON
--------------------------
'create a new table
Dim MyTable As New DataTable
'create a column
MyTable.Columns.Add(New DataColumn("Data"))
'Create Rows
Dim r As DataRow
Dim i As Integer
For i = 0 To 5
r = MyTable.NewRow()
r("Data") = "Item" & i.ToString()
MyTable.Rows.Add(r)
Next
MyTable.AcceptChanges()
'Ok Lets Print out the rows unmodified
Debug.WriteLine("------- Unmodified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Now lets Modify one element at row(1)
MyTable.Rows(1)("Data") = "Terry Burns"

'Ok Lets Print out the rows modified
Debug.WriteLine("------- Modified ---------")
For Each r In MyTable.Rows
Debug.WriteLine(r("Data"))
Next

'Declare an array of rows
Dim OriginalRows() As DataRow

'Get them from the Table using select statement
OriginalRows = MyTable.Select(Nothing, Nothing,
DataViewRowState.OriginalRows)

Debug.WriteLine("------- These 'SHOULD' be the original
ows ---------")
For Each r In OriginalRows
Debug.WriteLine(r("Data"))
Next
THIS IS THE RESULT
-------------------
------- Unmodified ---------
Item0
Item1
Item2
Item3
Item4
Item5
------- Modified ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5
------- These 'SHOULD' be the original rows ---------
Item0
Terry Burns
Item2
Item3
Item4
Item5

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

Do you mean this, that gives exactly the same resultst?

Cor

\\\
Module main
Public Sub main()
Dim myTable As New DataTable("myTable")
myTable.Columns.Add("myColumn")
For i As Integer = 0 To 9
Dim myrow As DataRow = myTable.NewRow()
myrow("myColumn") = "Cor " + i.ToString()
myTable.Rows.Add(myrow)
Next
myTable.AcceptChanges()
myTable.Rows(1)(0) = "Terry"
myTable.DefaultView.RowStateFilter = DataViewRowState.OriginalRows Dim dr() As DataRow = myTable.Select _
("myColumn = 'Cor 1'", Nothing,
myTable.DefaultView.RowStateFilter)
MessageBox.Show(dr(0)(0).ToString)
myTable.Rows(1).Delete()
dr = myTable.Select _
("myColumn = 'Cor 1'", Nothing, _
myTable.DefaultView.RowStateFilter)
dr(0).RejectChanges()
MessageBox.Show(dr(0)(0).ToString)
End Sub
End Module
///


Nov 20 '05 #32

This discussion thread is closed

Replies have been disabled for this discussion.