I am trying to update a database table that's attached to a table adapter and can't quite seem to be able to get the code to work. It was suggested that I use an update statement, but the person I was working with had no idea how to update a table adapter. Can someone please tell me how to update a table adapter please.

Thank you

Doug

Please clear your question little bit more how and where you want to update, and if possible post your code.

Prvnkmr,

I would like to update from the following code:

Public Class ExceptionEdit
    Private Sub ExceptionEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'MDRDataSet.scratchpad3' table. You can move, or remove it, as needed.
        Me.Scratchpad3TableAdapter.Fill(Me.MDRDataSet.scratchpad3)
    End Sub
    Private Sub SaveExceptionButton(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveexceptionsButton.Click
        Dim oCmd2 As System.Data.SqlClient.SqlCommand
        Dim oDr2 As System.Data.SqlClient.SqlDataReader
        oCmd2 = New System.Data.SqlClient.SqlCommand
        Try
            With oCmd2
                .Connection = New System.Data.SqlClient.SqlConnection("Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx")
                .Connection.Open()
                .CommandType = CommandType.StoredProcedure
                .Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate)
                .Parameters.AddWithValue("@payperiodenddate", payperiodenddate)
                .CommandText = "sp_exceptioncopy"
                oDr2 = .ExecuteReader()
                oCmd2.Connection.Close()
            End With
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            oCmd2.Connection.Close()
        End Try
        ExceptionsFinal.Show()
    End Sub

and as you can see, I've included my tableadapter in my code. The dataset that I'm referencing in my table adapter is the dataset that I'll need to update. I hope that offers some more clarity.

Thank you

Doug

This article has been dead for over six months. Start a new discussion instead.