thejeraldo
Well-known member
guys please help me on my error handling.. im kinda confused with this try catch thing in vb.net. yes i can catch exceptions but i wanna be able to catch exceptions specifically. like when a user entered an employee id that already exists. i want to do this so the users can understand the error and not in jargon so they will be able to give me feedback/reports if there is anybug.
when i do multiple exceptions i get an warning code like these : catch block never reach.... on the DuplicateNameException.
thanks a lot.
when i do multiple exceptions i get an warning code like these : catch block never reach.... on the DuplicateNameException.
thanks a lot.
VB.NET:
[FONT="Courier New"][SIZE="2"]Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Try
cmd = New OleDb.OleDbCommand
cmd.CommandType = CommandType.Text
strsave = "UPDATE tblemp SET "
strsave = strsave + "EmpID = '" + txEmpID.Text + "', "
strsave = strsave + "FirstName = '" + txFName.Text + "', "
strsave = strsave + "MiddleName = '" + txMName.Text + "', "
strsave = strsave + "LastName = '" + txLName.Text + "' "
strsave = strsave + "WHERE EmpID = '" + emp + "'"
cmd.CommandText = strsave
cmd.Connection = con
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "HRIS Error")
Catch ex As DuplicateNameException
MsgBox("Inform the user that the employee id she entered is not unique. or something like that")
End Try
End Sub[/SIZE][/FONT]