Doing a lot of input validation in VB.NET

Posted by Andy on Stack Overflow See other posts from Stack Overflow or by Andy
Published on 2010-01-12T09:05:52Z Indexed on 2010/05/29 22:02 UTC
Read the original article Hit count: 194

Filed under:
|

I have a form set up where users can enter their booking for a room at my college. I want to validate the user input to avoid SQL injection (my program uses a MS Access database) and also stop numbers and synbols in their name, etc.

I can do the validation fine, but there is to be a lot of validation and then methods executed only if all validation tests come back as true. I did have something like this:

If txtName.Text = "" Then
    frmBookErr.SetError(txtName, "Name field cannot be left blank.")
    fail = 1
Else
    frmBookErr.SetError(txtName, "")
    fail = 0
End If

And then check the fail variable, but it obviously gets overridden later in the form if one of the validation tests come back as true.

Can anyone provide some input into this? Thanks.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about validation