- Messages
- 13
- Reaction score
- 0
- Points
- 16
Good day, I am back again. Its been a long time when I visit this forum.Today I ask for a help to all the professional programmer here.I have this code.
Dim msg As Integer
msg = MsgBox("Do You Really Want To Delete This Employees Name:- '" & txtfname.Text & "' ?", MsgBoxStyle.YesNoCancel, "Delete Record ?")
If msg = DialogResult.Yes Then
Try
cmd.Connection = cn
cmd.CommandText = "Delete from tblemprecord where empid='" & txtidno.Text & "'"
cmd.ExecuteNonQuery()
MsgBox("Record Deleted Sucessfully.")
Catch ex As Exception
MsgBox(" Record Not Deleted.")
End Try
End If
'cn.Close()
End Sub
The problem is where I press button delete the message box pop up like this "Do You Really Want To Delete This Employees Name:- Name?" after you choose Yes the Try Catch Message Box "Record Not Deleted." pop up and nothing happen. Any help to find the error. I want the output "Do You Really Want To Delete This Employees Name:- Name?"if I choose Yes then the Msgbox Record Deleted Sucessfully" then the record will deleted in the database. by the way I'm using VB 2010 and MS Access 2010. and Im using Textbox to search the Id number.
Thanks for the help..
Dim msg As Integer
msg = MsgBox("Do You Really Want To Delete This Employees Name:- '" & txtfname.Text & "' ?", MsgBoxStyle.YesNoCancel, "Delete Record ?")
If msg = DialogResult.Yes Then
Try
cmd.Connection = cn
cmd.CommandText = "Delete from tblemprecord where empid='" & txtidno.Text & "'"
cmd.ExecuteNonQuery()
MsgBox("Record Deleted Sucessfully.")
Catch ex As Exception
MsgBox(" Record Not Deleted.")
End Try
End If
'cn.Close()
End Sub
The problem is where I press button delete the message box pop up like this "Do You Really Want To Delete This Employees Name:- Name?" after you choose Yes the Try Catch Message Box "Record Not Deleted." pop up and nothing happen. Any help to find the error. I want the output "Do You Really Want To Delete This Employees Name:- Name?"if I choose Yes then the Msgbox Record Deleted Sucessfully" then the record will deleted in the database. by the way I'm using VB 2010 and MS Access 2010. and Im using Textbox to search the Id number.
Thanks for the help..
Last edited: