473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

BeginEdit/EndEdit does not work

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

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

<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,

--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
Jun 27 '08 #1
5 6246
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

"Anil Gupte/iCinema.com" <an*******@icinema.comwrote in message
news:Op**************@TK2MSFTNGP03.phx.gbl...
>I have the following code:
Dim strContentInfo As String = "ContentID='" & CUID & "'"

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

<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,

--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv


Jun 27 '08 #2
Anil,

The RowState is unchanged because you are calling AcceptChanges.

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

Kerry Moorman

"Anil Gupte/iCinema.com" wrote:
I have the following code:
Dim strContentInfo As String = "ContentID='" & CUID & "'"

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

<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,

--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
Jun 27 '08 #3
Anil Gupte/iCinema.com wrote:
>
drContentInfo(0).BeginEdit()

drContentInfo(0).ItemArray(2) = NumPlays

drContentInfo(0).EndEdit()
At this point, the rowstate is changed.
>
drContentInfo(0).AcceptChanges()
AcceptChanges means the changes now become the original values, and all rows are
marked as unchanged.

It is typically called after successfully saving the changes to a database, or
after refreshing data from a database.
Jun 27 '08 #4
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.
--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
"Anil Gupte/iCinema.com" <an*******@icinema.comwrote in message
news:Op**************@TK2MSFTNGP03.phx.gbl...
>I have the following code:
Dim strContentInfo As String = "ContentID='" & CUID & "'"

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

<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,

--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv


Jun 27 '08 #5
See my answer in one of the other newsgroup you multiposted too.

Cor

"Anil Gupte/iCinema.com" <an*******@icinema.comschreef in bericht
news:Op**************@TK2MSFTNGP03.phx.gbl...
>I have the following code:
Dim strContentInfo As String = "ContentID='" & CUID & "'"

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

<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,

--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Allan Bredahl | last post by:
Hi All I have a bit of a problem with using a datarow to store data that is show in a form. On form load I set the Value/Text properties of my form elements to the specific Column values of...
2
by: Gav | last post by:
Hi all, I have a Datagrid and a save button if I change a value in a cell in the datagrid and hit the save button, it does not write the new value into the database. If I move the focus away...
1
by: Jason Huang | last post by:
Hi, I am wondering how to use the BeginEdit() and EndEdit() to update data, given in a web form. Would someone give me some advise? Thanks. Jason
13
by: CJ Taylor | last post by:
Alright on a DataRow you have the BeginEdit method Where can I catch an event that tells me that method is being fired or does one exist? Thanks, -CJ
0
by: George | last post by:
This is driving me crazy. I have a listview that has LabelEdit set to true. In the AfterLabelEdit event, I do my validation on the label text. If the label isn't valid, it sets e.canceledit = true...
3
by: Bryan | last post by:
I am calling BindingList.EndEdit during a 'TextChanged' sub for a texbox. In theory, the key should be pressed changing the value in the text box, the EndEdit call should append the changes to the...
2
by: Rob Dob | last post by:
How do I determine if there are any rows within the BindingSource that have changed prior to calling the EndEdit(). I need to do this in order to archive some records and if I call the EndEdit()...
3
nev
by: nev | last post by:
my textbox displays "hello" i change the value of textbox through code like this: textbox.text = "" then i do: bindingsource.endedit() tableadapter.update(dataset.datatable)
0
by: John Sheppard | last post by:
Hello there, I have a checked list box which I am trying to save to my dataset. The last tickbox I edit before saving, doesnt actually get saved to the underlying binding source. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.