Do u want to show error messages from the datasource or u want to validate fields on the form before performing data manipulation??? In case you want second scenario u can do as follows
Private Function ValidateFields() As Boolean
If Trim(TextBox1.Text) = "" Then
MessageBox.Show("Your message here")
TextBox1.Focus()
Exit Function
ElseIf Trim(TextBox2.Text) = "" Then
MessageBox.Show("Your message here"
TextBox2.Focus()
Exit Function
End If
Return True
End Function
Then let's say on Click of Save Button, call this function before performing data manipulation
If ValidateFields = True Then
'Perform Insert
End If
Otherwise you’ll have to use structured error handling Try...Catch...End Try block
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.