BeginEdit/EndEdit does not work

  • Thread starter Anil Gupte/iCinema.com
  • Start date

A

Anil Gupte/iCinema.com

I have the following code:
Dim strContentInfo As String = "ContentID='" & CUID & "'"

Dim drContentInfo As DataRow() =
GlobalDataSet.Tables("PaidContent").Select(strContentInfo)

<Some other stuff happens here to set NumPlays>

drContentInfo(0).BeginEdit()

drContentInfo(0).ItemArray(2) = NumPlays

drContentInfo(0).EndEdit()

drContentInfo(0).AcceptChanges()

GlobalDataSet.AcceptChanges()


However the values in the dataset or even the datarow are not changing. No
errors. I stepped through it to see what was happening and I coud not find
any problems. The HasErrors on the row is false, the RowError = "", but the
RowState says "Unchanged". What is wrong here?

TIA,
 
Ad

Advertisements

S

Scott M.

What happens if you skip all the extra code and just try:
drContentInfo(0).ItemArray(2) = NumPlays?

Generally, you don't really need the BeginEdit, EndEdit, AcceptChanges stuff
just to set a value.

-Scott
 
K

Kerry Moorman

Anil,

The RowState is unchanged because you are calling AcceptChanges.

AcceptChanges is a very misunderstood method that should almost never be
called.

Kerry Moorman
 
A

Anil Gupte/iCinema.com

OK, after three hours and lots of Googling (and posting to NewsGroups) I
finally fixed the problem. I changed

drContentInfo(0).ItemArray(2) = NumPlays
to
drContentInfo(0).Item("NumPlays") = NumPlays

and it works! Go figure. I am really curious though why this happened.

On another note, the RowState remains unchanged (I stepped through each
line) before and after the .AcceptChanges() I added
GlobalDataSet.AcceptChanges() thinking I needed to do that to fix the
problems. Anyway, now I have the problem fixed, I will remove the
..AcceptChanges.

Thanx for all the comments.
 
Ad

Advertisements

C

Cor Ligthert[MVP]

See my answer in one of the other newsgroup you multiposted too.

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