473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

' marks and sql trouble

27
Hello all!

i have a page where a user can type freely whatever he or she desires and it gets written to an access database via the Microsoft.Jet.OLEDB.4.0 connection using the following sql statement

Expand|Select|Wrap|Line Numbers
  1. sSQLB = "Update Profile SET txt1 = '" & txt1 & "', txt2 =' " & txt2 & "', txt3 = '" & txt3 & "', txt4 = '" & txt4 & "', txt5 = '" & txt5 & "' where USER_ID = " & USER_ID & ""
this works fine and enters the values into the database. The problem i face is when a user enters a ' sign. for example if a user was to write. " slider's car is the best " the ' sign in slider will cause an error stating the following "Syntax error (missing operator) in query expression"

i havnt come up with any idea of how to counteract this and im hoping someone here will.

i can see why the problem occurs its just on how to fix it i am lost.

Thanks
Jul 29 '07 #1
3 1126
ck9663
2,878 Expert 2GB
Hello all!

i have a page where a user can type freely whatever he or she desires and it gets written to an access database via the Microsoft.Jet.OLEDB.4.0 connection using the following sql statement

Expand|Select|Wrap|Line Numbers
  1. sSQLB = "Update Profile SET txt1 = '" & txt1 & "', txt2 =' " & txt2 & "', txt3 = '" & txt3 & "', txt4 = '" & txt4 & "', txt5 = '" & txt5 & "' where USER_ID = " & USER_ID & ""
this works fine and enters the values into the database. The problem i face is when a user enters a ' sign. for example if a user was to write. " slider's car is the best " the ' sign in slider will cause an error stating the following "Syntax error (missing operator) in query expression"

i havnt come up with any idea of how to counteract this and im hoping someone here will.

i can see why the problem occurs its just on how to fix it i am lost.

Thanks

create a function that will replace a ' with a " or replace ' with '''.
Jul 30 '07 #2
slider
27
create a function that will replace a ' with a " or replace ' with '''.
ow thats a great idea thanks a lot!. so i would have to create a function which looks for the ' signs and then replaces them before it writes to the database and then when retrieving the values it replaces the " with '.

hmm seems simple enough. can any one point me in the right direction of how to do this?
Jul 30 '07 #3
slider
27
ok i worked it all out
if anyone else is having the same sort of problem this code will let you replace on value for another

Expand|Select|Wrap|Line Numbers
  1. Dim string_var,string_find,string_replace
  2. string_var= "slider's"
  3. string_find= "'"
  4. string_replace="^"
  5. response.write Replace(string_var,string_find,string_replace)
  6.  
  7. slider^s
  8.  
hope this helps
Jul 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Stephen Poley | last post by:
One disadvantage of using a simple text editor to produce HTML is that it is relatively time-consuming to put in the proper typographical quotation marks and dashes. A round tuit having arrived...
63
by: Tristan Miller | last post by:
Greetings. Do any popular browsers correctly support <q>, at least for Western languages? I've noticed that Mozilla uses the standard English double-quote character, ", regardless of the lang...
9
by: Wayfarer | last post by:
Hi, I've been developing in Firebird, so I didn't notice this until today. When I use the <q> tag, IE 6 doesn't put quotes around the quotation. I tried specifically doing it in a stylesheet: ...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
7
by: Paradigm | last post by:
I am trying to create a recordset where some text fields are matching. The problem is that some of the text fields contain quotation marks. I have tried to create the sql string using replace eg....
0
by: Sebitti | last post by:
I have a web service that is called from vb6. If I send parameters from vb6 to webservice that has scandinavian marks the marks are changed into ?? characters. The returnvalue from the web service...
9
by: John Stivenson | last post by:
I'm using PHP 4.3.10 & MySQL 4.1.9. When I read UTF-8 string from database and echo it to the page I get only question marks. The number of question marks is equal to the real length of the...
31
by: The Bicycling Guitarist | last post by:
Hi. For many years I have been using &quot; for double quotation marks in the HTML code, but the opening and closing quotation marks render the same in my browser. I'm considering going through and...
12
by: chisholm | last post by:
I'm not an HTML expert and create all my web pages using MS Word 2000. I have looked around elsewhere for the answer to my question and it seems to be a problem with the HTML generated by MS Word...
3
by: praveenaj | last post by:
I was given to write a C program using Linked list to enter student marks, but i can't figure out how this node insertion works: how nodes are linked with each other??? A Computer Training...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.