• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ASP Question

Moonark

Senior member
I am currently working on writing a small search engine for our web site using an access database, and I was wondering if anyone knew how to prevent errors from occuring when I enter single quotes, double quotes, or spaces with no text? It works fine for strings and keywords, but not for the things mentioned above.
 
Use client side JavaScript to check for spaces with no text. I don't remember the syntax for Access, but you'll have to use 2 single quotes ('') or 2 double quotes ("&quot😉 to equal 1 of each in your SQL query.
 
what do you mean by errors? Is the user suppose to be able to enter in quotes?

You can always just strip out the single quotes, double quotes, or spaces with no text with the replace method.
 
The errors occur when I start off with a space or have multiple spaces in a string as well as using single quotes. How can I check to see waht they are entering?
 
Well after they enter in the string, you can format it to your liking. Lets say they enter the string on a page. Before you hit the database with the search string, check the string to see if it is formatted correctly and if it isn't then change it.

Use the ltrim method to take care of the spaces in the front.
ltrim(string)

Use the Replace method to take care of the double spaces.
replace(string, " ", " &quot😉

Use the Replace method to take care of the single quotes.
replace(string, "'", """&quot😉

This page is a good reference on vbscript.
 
Back
Top