ok wondering if any 1 knows why my delete row from database is not working.
After i click delete the data seems to be deleted as well i mean it actually removes from the databound DGV when i use the scoller to search for the deleted row i can not find it but if i run a query for the row i delete the row i deleted appears again.
this is the code i am trying to use
After i click delete the data seems to be deleted as well i mean it actually removes from the databound DGV when i use the scoller to search for the deleted row i can not find it but if i run a query for the row i delete the row i deleted appears again.
this is the code i am trying to use
Code:
Private Sub Btn_Delete1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Btn_Delete1.MouseClick
If Profile_NameTextBox.Text = "" Then
MsgBox("No Profile selected")
Else
If MsgBox("Confirm Profile '" & Profile_NameTextBox.Text & "' and all associated backed Up Items, To be Deleted.", MsgBoxStyle.YesNoCancel) = MsgBoxResult.Yes Then
If slct_LOC = 0 Then
Try
My.Computer.FileSystem.DeleteDirectory(My.Computer.FileSystem.CurrentDirectory & "\Backups\" & Profile_NameTextBox.Text, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin)
'Throw New System.Exception("Directory not found")
Catch ex As Exception
' MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
MessageBox.Show(Environment.NewLine & "PROFILE WAS SUCCESSFULLY DELETED..." & Environment.NewLine & Environment.NewLine & "Unfortuantly the associated folder could not be found" & Environment.NewLine & "Please manually delete this folder. " & Environment.NewLine & Environment.NewLine & ex.TargetSite.Name, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
ElseIf slct_LOC = 1 Then
Try
My.Computer.FileSystem.DeleteDirectory(DestinationTextBox.Text, FileIO.RecycleOption.SendToRecycleBin)
Catch ex As Exception
' MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
MessageBox.Show(Environment.NewLine & "PROFILE WAS SUCCESSFULLY DELETED..." & Environment.NewLine & Environment.NewLine & "Unfortuantly the associated folder could not be found" & Environment.NewLine & "Please manually delete this folder. " & Environment.NewLine & Environment.NewLine & ex.TargetSite.Name, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End If
'Search all rows in table for Profile name items and delete
For Each AttachedFile As DataRow In ItemsdatabaseDataSet.Tables(0).Rows
If (AttachedFile("item_profile") = Profile_NameTextBox.Text) Then
''this does not delete
AttachedFile.Delete()
End If
Next
ItemsdatabaseDataSet.Tables(0).AcceptChanges()
'' this does not delete
Me.ProfilestableBindingSource.RemoveCurrent()
End If
SearchTextBox.Text = ""
End If
End Sub