locked
Delete All Rows From An MS Access Table Using The TableAdapter RRS feed

  • Question

  • Hi:

    I use an ms access table to temporarily hold data for a report after all the data manipulation is complete. 

    Can you tell me how to use the TableAdapter for this table to delete all rows once the report has been printed. Thanks.



    Thursday, August 6, 2020 11:03 PM

Answers

  • Hello,

    You can try the following from here

    https://github.com/karenpayneoregon/WorkingWithAccessDatabases/tree/master/TableAdapter1

    In the .xsd file, select the table, right click on the first arrow then select the second arrow item.

    On the second page

    Delete everything after the table name (the highlighted text)

    Follow through (I named mine DeleteQuery) and call it.

    Private Sub DeleteAllButton_Click(sender As Object, e As EventArgs) Handles DeleteAllButton.Click
        Dim results = EmployeesTableAdapter.DeleteQuery()
        If results > 0 Then
            MessageBox.Show($"{results} records delete")
        End If
    End Sub

    Make sure Copy always is not selected.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Friday, August 7, 2020 12:12 AM

All replies

  • Hello,

    You can try the following from here

    https://github.com/karenpayneoregon/WorkingWithAccessDatabases/tree/master/TableAdapter1

    In the .xsd file, select the table, right click on the first arrow then select the second arrow item.

    On the second page

    Delete everything after the table name (the highlighted text)

    Follow through (I named mine DeleteQuery) and call it.

    Private Sub DeleteAllButton_Click(sender As Object, e As EventArgs) Handles DeleteAllButton.Click
        Dim results = EmployeesTableAdapter.DeleteQuery()
        If results > 0 Then
            MessageBox.Show($"{results} records delete")
        End If
    End Sub

    Make sure Copy always is not selected.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Friday, August 7, 2020 12:12 AM
  • Hi:

    That worked perfectly. Thanks!

    Friday, August 7, 2020 7:10 PM