Re: Update SET ?
From: Ray Costanzo [MVP] (my)
Date: 08/30/04
- Previous message: Bob Barrows [MVP]: "Re: Update SET ?"
- In reply to: TomT: "Update SET ?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 30 Aug 2004 15:24:59 -0400
As for the "
This isn't an issue with building your query. It is merely an issue with
building a string. Example:
sVar = "The sign over the door says "Employees Only.""
When this is interpreted by the scripting host, it will see that " before
Employees and take that to mean the end of your string. Then, any
characters that appear after it will just cause confusion, hence an error.
The way to "escape" quotes in VB Script (is that what you're using) is by
doubling them. IE:
sVar = "The sign over the door says ""Employees Only."""
--------------------------------------
As for the '
' is the delimiter used mostly for text in SQL queries. If you have a ' in
your text that you're updating, inserting, or whatever, you need to "escape"
that for the query. This is done by doubling the ' character. So, if you
have this:
sLastname = "O'Brien"
You'd want to essentially do:
sSQL = "select something from somewhere where lastname='" &
Replace(sLastname, "'", "''") & "'"
That would produce a sSQL value of
select something from somewhere where lastname='O''Brien'
---------------------------------------
For more detailed assistance, post your code and your errors when you are
posting about code and errors.
Ray at work
"TomT" <tomt@adslweb.co.uk> wrote in message
news:41337b84$0$20248$cc9e4d1f@news-text.dial.pipex.com...
> Taking data from a form, and using UPDATE tablename SET
>
> Seems to be working fine... EXCEPT..
>
> Certain characters cause an error when the update happens.
>
> These include:
> ' "
>
> ' causes an SQL error (Syntax error (missing operator) in query
> expression)
>
> " data after or between the "" is not displayed..
>
> How do I trap these ? and stop these errors ?
>
> Thanks
>
- Previous message: Bob Barrows [MVP]: "Re: Update SET ?"
- In reply to: TomT: "Update SET ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|