Results 1 to 1 of 1

Thread: Data Adapter Update

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279

    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.
    Last edited by Dman; Apr 8th, 2004 at 12:52 PM.
    A cynic knows the price of everything but the value of nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width