473,385 Members | 1,379 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,385 software developers and data experts.

How to insert text include ( " or ' ) to database?

Kosal
68
Hi I had some problem with asp when i insert string include ' or " in the string I cannot insert to database and error message like:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''For centuries China stood as a leading civilization, outpacing the rest of the world in the arts and sciences. But in the 19th and early 20th centuries, China was beset by civil unrest, major famines, military defeats, and foreign occupation. After World Wa'.
/ptmasia/admin/au_country_exe.asp, line 21


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Avant Browser; .NET CLR 2.0.50727)

Page:
POST 771 bytes to /ptmasia/admin/au_country_exe.asp

POST Data:
idregion=1&country=China&information=For+centuries +China+stood+as+a+leading+civilization%2C+outpacin g+the+rest+of+the+world+in+the+arts+and+sciences.+ But+in+the+19th+and+early+20th+centuries%2C+China+ . . .

Please kinldy help me to solve this problem
Aug 11 '07 #1
2 1693
jhardman
3,406 Expert 2GB
OK, I'll help. But do I have to do it kindly?

Please remember that quote marks (") and single quote marks (') are considered special characters in either VBScript or SQL. Since you are using both to script the page and connect to the db, there are several opportunities to create errors unless you replace them with non-special characters. If you need those characters in the string for the purposes of searching or cataloguing, then you can double them, this let's SQL know that you intend the special character to be inserted in the db:
Expand|Select|Wrap|Line Numbers
  1. description = replace (request("description"), "'", "''") 
  2. 'places two apostrophe's everywhere you have one
On the other hand, if you just want these characters for display purposes, you should "escape them" or replace them entirely with something that will look the same, but not cause errors:
Expand|Select|Wrap|Line Numbers
  1. description = replace (request("description"), """, """) 
  2. 'replaces quote mark with the HTML character code for quote mark
Aug 13 '07 #2
guny
3
or else, you may use chr(34) to substitute ", chr(39) to substitute ' .
Don't forget to use & before and after the code
For instance, text = I'd love to use "Hello World"
Then
string = "I" & chr(39) & "d love to use " & chr(34) & "Hello World" & chr(34)
Aug 16 '07 #3

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

Similar topics

9
by: Luc Dal | last post by:
Hello, I've serious problem using ASP under WindowsXP sp2. I get the following reply (sorry it's in french) Erreur de compilation Microsoft VBScript error '800a0401' Fin d'instruction...
4
by: hao | last post by:
Hi, all When I use ASP to insert an record to a database, I got some errors and can not insert any value with Chinese Char. The only way I can do that is use "rst1.Addnew...rst1.update". Anyone...
17
by: NuB | last post by:
I have a sql query that is doing an update of records, how can I add NULL to the field in the database if the field on my screen is blank? example: I have 5 textboxes, and a user can leave some...
3
mmarif4u
by: mmarif4u | last post by:
Hi everybody, I already post a thread like this but that was in mysql. Here i have a problem with all the code,, <?php // signup.php include("common.php"); include("db.php");
1
by: oanhhuynh | last post by:
Hi, I'm designing 1 form include 2 Unbound Object Frame to insert image and memo that describe the product. On database in Access have 2 fields image and description with OLE Object property ...
0
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include...
7
by: dongletran06 | last post by:
Hi, Please help me find out what wrong with my codes in inputting from my form to mysql database using drop down menu. Below is the codes I used. Only the drop down is not working but the "input...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
7
by: tarunkhatri | last post by:
Hi, I want to insert multiple rows in a database table, from an submit form. But not able to trouble shoot the problem in my code. Following is the code. <form action=test_insert.php...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.