Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to deal with the character ' in a SQL string

Dear all,

Please give me some hints to tackle the following problem: -

strSQL = "Select location from restaurant where name = '" & strName & "'"
rstResult.open strsql, adoconnection, adOpenKeyset, adLockOptimistic

** if the string variable strName contains the character ['], i.e.
Benjimin's Restaurant, then error occurs.

Thanks in advance!

Keith

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default How to deal with the character ' in a SQL string

Try doubling up the quotes before running the SQL

Benjimin''s Restaurant

(that's two single quotes, not a double quote)

Tim

"KS Wong" wrote in message
...
Dear all,

Please give me some hints to tackle the following problem: -

strSQL = "Select location from restaurant where name = '" & strName & "'"
rstResult.open strsql, adoconnection, adOpenKeyset, adLockOptimistic

** if the string variable strName contains the character ['], i.e.
Benjimin's Restaurant, then error occurs.

Thanks in advance!

Keith



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Has anyone made a Deal or No Deal Gamebord [email protected] Excel Discussion (Misc queries) 2 April 17th 08 12:12 AM
Excel-Match 1st text character in a string to a known character? bushlite Excel Worksheet Functions 2 January 15th 07 06:36 PM
Insert Character in a String Laguna Excel Programming 1 July 7th 05 01:28 PM
Function to return Character Position of Xth character within a string Andibevan[_2_] Excel Programming 4 June 9th 05 03:24 PM
Finding a particular character in a string using VBA [email protected] Excel Programming 0 September 14th 04 04:16 PM


All times are GMT +1. The time now is 06:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"