473,404 Members | 2,137 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,404 software developers and data experts.

Strange Dataset update problem.

I'm experiencing a strange Dataset Update problem with my application.
I have a dataset which has a table holding a set of customer information
records. (address, contact, info, etc.)
I have a series of ComboBoxes (Client Number for selection), and text fields
to show the other data bound to this Dataset.table

If I change a value for the first client in the list, and press my update
client button, the data is successfully updated to the database.
If I change a value for another client (email address, for instance), the
value is not saved back to the database.

In both instances, HasChanges will report true. In the first instance
(changing the first client in the list), the DebugXML shows the row with the
new value.
In the second instance (another client), it shows both the first row, and
the second row (not the row that has actually changed), but neither shows
any changed values, they are all unchanged.
I have included the Subroutine that handles the Update Button click event,
which does the Dataset Update.

The DataAdapter is filled through a stored procedure, and the update command
is also a stored procedure. All parameters are set to the correct source
columns.

This just has me totally baffled, and I hope someone can help me understand
this problem.

Thanks, Kevin

Private Sub btnUpdateClient_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdateClient.Click
Me.connExpress.Open() 'Open the connection
Try

Me.BindingContext(Me.DsCustomerInfo1.CW_customerin fo).EndCurrentEdit()
MsgBox("Has Changes: " & Me.DsCustomerInfo1.HasChanges.ToString)
If Me.DsCustomerInfo1.HasChanges Then
Me.DsCustomerInfo1.GetChanges.WriteXml("c:\test\de bug.xml")
End If
Me.daCustomerInfo.Update(Me.DsCustomerInfo1, "CW_customerinfo")
PopulateLicenceInfo()
ClientInfoUpdated = False
ClientInfoUpdate()
Main.AddEventLog(appPermissions.UserID, appSettings.DistributorID,
"6", Me.cmbClientNumber.Tag, "Update Client Data", "",
Me.cmbClientNumber.Text, "", "", "", "")
Me.errUpdatePending.SetError(Me.btnUpdateClient, "")
Me.DsCustomerInfo1.AcceptChanges()
Catch ex As Exception
MsgBox(ex.ToString & vbCrLf & vbCrLf & ex.Source.ToString & vbCrLf &
vbCrLf & ex.StackTrace.ToString, MsgBoxStyle.Critical, "SQL Error")
Me.DsCustomerInfo1.RejectChanges()
End Try
Me.connExpress.Close() 'Close the connection
End Sub

Nov 21 '05 #1
9 1533
Kevin,

In 80% when this problem is showed is this the solution.

Before the update (or check for changes)
BindingContext(ds.Tables(0)).EndCurrentEdit()

Data is pushed in the datatables after a rowchange (or after this command)

I hope this helps?

Cor
Nov 21 '05 #2
Thanks Cor, but I do an EndCurrentEdit already, and check for HasChanges.
If it's the first row, everything works as expected, if it's any other row,
it goes haywire and doesn't work correctly.

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

In 80% when this problem is showed is this the solution.

Before the update (or check for changes)
BindingContext(ds.Tables(0)).EndCurrentEdit()

Data is pushed in the datatables after a rowchange (or after this command)

I hope this helps?

Cor

Nov 21 '05 #3
Kevin,

Sorry, I should have seen it. I have been strugled long time myself using a
combobox with a binded textbox.

I have given it up. It is the most buggy control there is in my (and
probably Herfrieds) opinion.
When you can avoid them it is a great control by the way.

I have seen the most strange behaviour with that binded combobox, sent some
samples too this newsgroup and the newsgroup vb.controls. However, never got
one reaction. (Just because nobody knows the answers).

Sorry,

However maybe we see here a solution what is good for me as well.

Cor
Nov 21 '05 #4
Yes, I've been having problems with databound ComboBoxes and the Tag
Property not changing to the new selected value until after all events have
been comitted (there doesn't seem to be a way from any ComboBox change event
to get the bound tag value of the new selected item, I always get the tag
value for the previous item). I'm not sure if I'm explaining that well.

For instance, if I have my value member bound to a Client Number, and the
Tag bound to the the Primary Key column (UniqueID), during the change
events, the SelectedValue and Tag are pointing to two different records (The
SelectedValue points to the new row, the tag points to the previously
selected row). After all change events have completed however, the Tag
contains the correct value for the newly selected record.

This is causing me other problems, but I don't think it has a bearing on
this one (at least I hope it doesn't)
"Cor Ligthert" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
Kevin,

Sorry, I should have seen it. I have been strugled long time myself using a combobox with a binded textbox.

I have given it up. It is the most buggy control there is in my (and
probably Herfrieds) opinion.
When you can avoid them it is a great control by the way.

I have seen the most strange behaviour with that binded combobox, sent some samples too this newsgroup and the newsgroup vb.controls. However, never got one reaction. (Just because nobody knows the answers).

Sorry,

However maybe we see here a solution what is good for me as well.

Cor

Nov 21 '05 #5
Hi Cor,

This has gotten even stranger.

Ok, so for an update. If I cycle through more than one client, each client I
"leave" ends up having it's HasChanges property set to true. I suspect this
is due to bound text fields that in the DB are NULL, but since they are
bound to blank TXT Fields, it's getting changed to "" or Nothing, not
DBNull.Value.

Anyway, unless I leave the Client (row), the one I Just changed won't be
updated. However, if I DO leave the Row, my changes will be updated.

I'm at a loss why it works correctly for the first row however. Is there
another Event called when the row is changed by selecting an item in the
ComboBox that I might be missing? All of these controls had their
Databinding set at Design Time.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
Kevin,

Sorry, I should have seen it. I have been strugled long time myself using a combobox with a binded textbox.

I have given it up. It is the most buggy control there is in my (and
probably Herfrieds) opinion.
When you can avoid them it is a great control by the way.

I have seen the most strange behaviour with that binded combobox, sent some samples too this newsgroup and the newsgroup vb.controls. However, never got one reaction. (Just because nobody knows the answers).

Sorry,

However maybe we see here a solution what is good for me as well.

Cor

Nov 21 '05 #6

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

In 80% when this problem is showed is this the solution.

Before the update (or check for changes)
BindingContext(ds.Tables(0)).EndCurrentEdit()

Data is pushed in the datatables after a rowchange (or after this command)

I hope this helps?

Cor


What's the difference between: BindingContext(ds.Tables(0)).EndCurrentEdit()
and (CurrencyManager).EndCurrentEdit(),
and when do one over the other...

Thanks....

Bruce
Nov 21 '05 #7
Bruce it is the same, only not instanced that currencymanager
Nov 21 '05 #8
I have solved this problem, though I'm not pleased with how I have to do it.

I am save the currently selected index of the selection combobox, and then
set the selectedindex to -1, and then restore it to the saved selection.
This triggers the Row Change or whatever event is supposed to happen, in the
background, which sets the HasChanges flag correctly. Now all of my updates
are correctly saved. I just need to update my code to pop up the alerter
when actual changes have been made.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
Kevin,

Sorry, I should have seen it. I have been strugled long time myself using a combobox with a binded textbox.

I have given it up. It is the most buggy control there is in my (and
probably Herfrieds) opinion.
When you can avoid them it is a great control by the way.

I have seen the most strange behaviour with that binded combobox, sent some samples too this newsgroup and the newsgroup vb.controls. However, never got one reaction. (Just because nobody knows the answers).

Sorry,

However maybe we see here a solution what is good for me as well.

Cor

Nov 21 '05 #9
Kevin,

Thanks for letting us know, I stepped out of this one, because I had had
myself to much problems with bounded comboboxes (when not used as
dropdownlist because than I have never a problem).

Cor
Nov 21 '05 #10

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

Similar topics

9
by: Christian Hubinger | last post by:
Hi! I've implemented some DropDown list in ASP.NET that use Ajax to fetch the data from the server. The javascript is written to call cascading to the bottom most dropdown in order to update...
2
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
1
by: John | last post by:
Hi I have a perfectly working vs 2003 winform data app. All the data access code has been generated using the data adapter wizard and then pasted into the app. I had to add a new field in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.