Problem solve Get help with specific problems with your technologies, process and projects.

Darn that apostrophe

Here's a simple, elegant tip about eschewing the commotion caused by apostrophes in user-input database entries

Darn that apostrophe
Bruce Wood

Your tips editor loves simple tips. These are tips that solve a big problem with a little fix. "An elegant solution," they used to call these things in engineering school. Here's a simple, elegant tip from reader Bruce Wood, about eschewing the commotion caused by apostrophes in user-input database entries.

When saving info to a database table the apostrophe character causes run-time errors. Most databases do not allow the use of the apostrophe as it is interpreted as a new field starting. This will cause syntax errors. Here is a very simple technique that overcomes this problem by handling it when it is typed in the form.

'Put this code in the keypress event
'of the selected text control

Select Case KeyAscii
  Case 39     'apostrophe
    KeyAscii = 96  'backwards apostrophe
  Case Else
    KeyAscii = KeyAscii
End Select
------------------------------------------------------
Thanks, Bruce. For your interest in SearchVB, we'll be sending you a SearchVB denim shirt.
This was last published in February 2001

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

SearchCloudApplications

Close