Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Trying to Delete Row From DataSet and then Database

$
0
0

Using VS 2013 Community, 2014 SQL Express and Windows Pro 8.1.

I have the Agents Table (AgentsDataSet) as the binding source for the Controls on the form shown below.   I am trying to delete the shown row using the code block below.  I get an message saying an unhandled exception has occured.  I found no information there.

Could someone please tell me what is missing from the code?

Thanks

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        'Locate the row to delete

        Dim oldAgentsRow As AgentsDataSet.AgentsRow
        oldAgentsRow = AgentsDataSet._Agents.FindByagentname("ComboBox1.SelectedValue")

        'Delete the row from AgentsDataSet
        Try
            oldAgentsRow.Delete()
            MsgBox("Update Successful")

        Catch ex As Exception
            MsgBox("Delete Failed")

            'Delete Row from Database
            Try
                Me.AgentsTableAdapter.Update(Me.AgentsDataSet._Agents)
                MsgBox("Update Successful")

        Catch es As Exception
                MsgBox("Update Failed")

            End Try
        End Try



    End Sub


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>