K
Kevin Hodgson
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_customerinfo).EndCurrentEdit()
MsgBox("Has Changes: " & Me.DsCustomerInfo1.HasChanges.ToString)
If Me.DsCustomerInfo1.HasChanges Then
Me.DsCustomerInfo1.GetChanges.WriteXml("c:\test\debug.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
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_customerinfo).EndCurrentEdit()
MsgBox("Has Changes: " & Me.DsCustomerInfo1.HasChanges.ToString)
If Me.DsCustomerInfo1.HasChanges Then
Me.DsCustomerInfo1.GetChanges.WriteXml("c:\test\debug.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