DAAB UpdateDataSet doesn't Update when used in WebService?

Topics: Data Access Application Block
Mar 3, 2008 at 5:12 PM
Edited Mar 3, 2008 at 5:14 PM
Hi,
I have a webservice that provides data interface to my client WinForms app.
I seem to have an issue whereby the UpdateDataSet method doesn't actually apply the changed values to the SQL table.
(Note: I have used UpdateDataSet successfully in a client that is connecting directly to the SQL DB without a WebService intermediary)

Client code extract:

Private sub SaveInvoices()
try
Dim dsChanges As DataSet = Me.dsInvoices.GetChanges
Dim iRE As Integer = serviceProxy.Finance-InvoiceDetail-Update(dsChanges)
catch ...
Messagebox.show....
End sub


WebService code extract:


<WebMethod()> _
Public Function Finance-InvoiceDetail-Update(ByVal dsInvoices As DataSet) As Integer
Try
Me.CheckUserToken()

dbCmd = db.GetStoredProcCommand("usp-2-Finance-PODetail-UPDATE")
db.AddInParameter(dbCmd, "POID", DbType.Int32, DataRowVersion.Current) 'The PK (not editable)
db.AddInParameter(dbCmd, "ClinicInvoiceRef", DbType.String, DataRowVersion.Current)
db.AddInParameter(dbCmd, "ClinicInvoiceRec", DbType.Date, DataRowVersion.Current)
db.AddInParameter(dbCmd, "Locked", DbType.Boolean, DataRowVersion.Current)
db.AddInParameter(dbCmd, "Accepted", DbType.Boolean, DataRowVersion.Current)
db.AddInParameter(dbCmd, "DateAccepted", DbType.Date, DataRowVersion.Current)

'Perform a batch update call.
Dim iRowsEffected As Integer = db.UpdateDataSet(dsInvoices, "Invoices", Nothing, dbCmd, Nothing, UpdateBehavior.Standard)

Return iRowsEffected

Catch ex As Exception
Throw ex
End Try
End Function

So for example, I have traced the change of the boolean flag "Locked" from the client datagridview through to the service function and the flag is being passed as the value I changed it to in the UI. So far so good, however, the UpdateDataSet call return zero rows effected.

Checking my table in SQLEntMgr also shows this is the case (value unchanged from when first loaded by client)

Can anyone throw any light onto what else I ought to check please?

TIA,
Alec
Mar 4, 2008 at 8:51 AM
Ah-HA!
(humble-pie being eaten).
I found my problem. Because the dataset contains more columns than just the fields being modified, I needed to specify the source columns in the parameters, so

...
dbCmd = db.GetStoredProcCommand("usp-2-Finance-PODetail-UPDATE")
db.AddInParameter(dbCmd, "POID", DbType.Int32, DataRowVersion.Current) 'The PK (not editable)
...
db.AddInParameter(dbCmd, "Locked", DbType.Boolean, DataRowVersion.Current)
...


... becomes

db.AddInParameter(dbCmd, "POID", DbType.Int32, "POID", DataRowVersion.Current)
db.AddInParameter(dbCmd, "Locked", DbType.Boolean, "Locked", DataRowVersion.Current)
... etc

So, I feel like a plum, but am happy I sorted my own problem out!

Alec