-
Data Adapter Update
I have a question about updating a database from a dataset. I have an application with fields which I populated with a web service that uses a stored procedure. The stored procedure uses a join statement. Once the form is populated the user can then edit the data and save the changes back to the database. I wanted to just pass the dataset back to the web service and use the SQLDataAdapter.Update method to save the changes to the database. Here are the rudiments of my web service minus all of my commented code:
<WebMethod()> Public Function SaveEdit(ByVal ds As DataSet) As String
Dim con As New SqlClient.SqlConnection(connectstring)
Dim adpt As SqlClient.SqlDataAdapter
Dim cb As New SqlClient.SqlCommandBuilder(adpt)
Dim errmsg As String
Try
con.Open()
adpt.UpdateCommand = cb.GetUpdateCommand
adpt.Update(ds, "ClassDetails")
Return "Good"
Catch e As Exception
errmsg = e.Message & " " & e.ToString
Return errmsg
Finally
End Try
End Function
After several variations I can't get it to work. Am I wrong in trying to save this dataset back to the database because it is the product of a join statement rather than several data adapters pulling in the rows from each table separately?
Any help would be appreciated.