Failed Record Deletion in Database : Visual Studio 2015: MS Access 2019

Fred Peters 1 Reputation point
2021-04-02T21:36:17.14+00:00

When opening the form and following the Form structure to delete the record, it does delete from my Form.datagridview, but when closing and reloading the form, the record is there.

my source database shows in the 'server explorer' with the "red x" and remains red throughout the life of the form, start to finish and restart.

I'm wracking my brains. My poor brains. I have tries myriads of tableadapter and binding source combinations, to no avail.
Does anyone have any ideas?

 Public Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
        If Me.EnableEditingCheckbox.Checked Then

            If Me.AddNewButton.Text = "Cancel" Then
                Exit Sub
            End If

            If Not DataGridView1.Rows.Count = 0 Then
                Try

                    Dim result As DialogResult

                    result = MessageBox.Show("Do you want to permantely DELETE the selected record?", "DELETION Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

                    If result = DialogResult.Yes Then

                        Me.TTimeBindingSource.RemoveCurrent()
                        Me.TTimeBindingSource.EndEdit()
                        Me.TTimeTableAdapter.Update(DocketMV4DataSet1Apr1.tTime)

                    End If

                Catch ex As Exception

                End Try
            End If

        Else
            MessageBox.Show("Access Denied!" & Environment.NewLine & "You need permission to perform this action" & Environment.NewLine & Environment.NewLine & "Please contact the programmer or ask Google!", "Delete operation failed", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            Return
    Exit Sub
        End If

    End Sub
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,568 questions
Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
820 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,031 Reputation points
    2021-04-02T22:47:42.53+00:00

    If the database is part of the project such as a MS-Access database or a local SQL-Server database, right click on the database in solution explorer, select properties. Look at Copy to Output folder, for you set it to copy if newer as the default is to copy always which means each time the project runs a fresh copy is placed in the debug folder wiping former changes.

    If the database is a SQL-Server (server based or express edition) this should not happen when you have a primary key set.

    Lastly, make sure there is a delete command being generated if this is using a TableAdapter (highly not recommend using them).


  2. Fred Peters 1 Reputation point
    2021-04-05T02:46:48.55+00:00

    Thank You Karen,

    I am reading your articles/postings you referenced earlier.
    I was not able to make a connection string to an accbd. "not registered" Thats why I changed my data back into an mdb.
    I AM able to delete records, but not update and am trying to work through that.
    Thank you. Its a nagging problem, but when resolved, I'm sure I'll be that much better of a ??

    0 comments No comments