How to validate single quotes in vb.net

How to validate single quotes in vb.net
One of the most common problems in submitting vb forms to a database using access is the dreaded single quote. The database reads single quotes as part of the syntax of the access query and invariable produces an error. so we can avoid single quotes with this validation1 function
...........................................................................................................................................................
Private Sub Txtname_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Txtname.KeyPress

validation1(e)

End Sub

'function for single quotes validation
Public Sub validation1(ByVal e As System.Windows.Forms.KeyPressEventArgs)

Dim i As String = e.KeyChar.ToString()
If i = "'" Then ' for single quotes validation
e.Handled = True

End If
End Sub
---------------------------------------------------------------------------------------------

1 comment:

Anonymous said...

The information here is great. I will invite my friends here.

Thanks