A
a
Can someone please help me with the use of Datasets and Webservices to add
new reords to a database. I keep getting duplicate records added. When the
Update call returns, I have 2 copies of the new record in my dataset, one
with the dataset assigned ID, and on that comes back from the DB (my update
stored procedure is set to refresh the dataset.)
Also, I used to get strange things when using 'Autonumber' type fields. For
instance, if I delete the record with ID=10, then add a new record to the
dataset, I will get an error. Not sure why that stopped.
Here is my webservice code:
<WebMethod()> _
Public Function myGetDsTask() As dsTask
Dim ds As New dsTask
Me.daGroup.Fill(ds, "tblGroup")
Me.daTask.Fill(ds, "tblTask")
Return ds
End Function
<WebMethod()> _
Public Function myUpdateDsTask(ByVal ds As dsTask) As dsTask
Me.daGroup.Update(ds, "tblGroup")
Me.daTask.Update(ds, "tblTask")
Return ds
End Function
and here is the call from the form:
Public Shared Function GetDSTask() As wsTask.dsTask
If IsNothing(dsTask1) Then
dsTask1 = New wsTask.dsTask
ws.Url = strConnection
dsTask1.Merge(ws.myGetDsTask)
End If
Return dsTask1
End Function
Public Shared Function UpdateDSTask()
If dsTask1.HasChanges Then
ws.Url = strConnection
Dim dsTemp As New wsTask.dsTask
dsTemp.Merge(dsTask1.GetChanges)
dsTask1.Merge(ws.myUpdateDsTask(dsTemp))
End If
End Function
My dataset is set to AutoIncrementSeed = 0 and AutoIncrementStep = -1
What am I doing wrong? Do I 'need' to have a non-identity primary key? What
will happen when I introduce 'relationships' to the dataset.
THanks gang!
Kevin
new reords to a database. I keep getting duplicate records added. When the
Update call returns, I have 2 copies of the new record in my dataset, one
with the dataset assigned ID, and on that comes back from the DB (my update
stored procedure is set to refresh the dataset.)
Also, I used to get strange things when using 'Autonumber' type fields. For
instance, if I delete the record with ID=10, then add a new record to the
dataset, I will get an error. Not sure why that stopped.
Here is my webservice code:
<WebMethod()> _
Public Function myGetDsTask() As dsTask
Dim ds As New dsTask
Me.daGroup.Fill(ds, "tblGroup")
Me.daTask.Fill(ds, "tblTask")
Return ds
End Function
<WebMethod()> _
Public Function myUpdateDsTask(ByVal ds As dsTask) As dsTask
Me.daGroup.Update(ds, "tblGroup")
Me.daTask.Update(ds, "tblTask")
Return ds
End Function
and here is the call from the form:
Public Shared Function GetDSTask() As wsTask.dsTask
If IsNothing(dsTask1) Then
dsTask1 = New wsTask.dsTask
ws.Url = strConnection
dsTask1.Merge(ws.myGetDsTask)
End If
Return dsTask1
End Function
Public Shared Function UpdateDSTask()
If dsTask1.HasChanges Then
ws.Url = strConnection
Dim dsTemp As New wsTask.dsTask
dsTemp.Merge(dsTask1.GetChanges)
dsTask1.Merge(ws.myUpdateDsTask(dsTemp))
End If
End Function
My dataset is set to AutoIncrementSeed = 0 and AutoIncrementStep = -1
What am I doing wrong? Do I 'need' to have a non-identity primary key? What
will happen when I introduce 'relationships' to the dataset.
THanks gang!
Kevin