Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB.NET
If ValidateData() = False Then
          Exit Sub
      End If
      If UpdateData() Then
          If MyMode = "Add" Then

              MsgBox("New Activity Added Successfully !", CType(vbInformation + vbOKOnly, MsgBoxStyle), "Update Status")
              PopulateList()
              ClearMyCtls()
              txtStudentID.Text = GetNextPrimaryKey(con, "Activity", "Activity_ID").ToString("######000")
              txtStudentID.Focus()

              Exit Sub
          End If
Posted
Comments
ZurdoDev 13-Jan-16 9:18am    
What is a trapping? Please explain your question much more clearly.
ElLo25 13-Jan-16 9:21am    
an error message that will pop-up for example activity already exist and it will automatically not save to database
ZurdoDev 13-Jan-16 9:26am    
Sounds like that should be part of your ValidateData method. Validate whether or not the record exists.
ElLo25 17-Jan-16 20:08pm    
how?
ZurdoDev 17-Jan-16 21:19pm    
How what exactly? Do you know how to write code to access a database? If not, you can use the SqlConnection and the SqlCommand objects. Many examples online.

1 solution

As mentioned in comments, I suggest you call into your db during your Validate method to determine if the record exists or not. Then handle from there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900