I need to run a 'select' query from VB6, that might contain a string with tags

Posted on 2006-07-13
Last Modified: 2008-02-01
I need to run a 'select' query from VB6, that might contain a string with tags in it,
for example:
 DB.OpenRecordset( "select * from X  where x.Name ='" & nameString & "'"
if the nameString variable contains tag in it, the operation will fail.
what can I do to overcome this problem.
Question by:yossikally
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 92

Expert Comment

by:Patrick Matthews
ID: 17098809
Hi yossikally,

Please give an example of a nameString that causes a problem.


LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 125 total points
ID: 17098893
DB.OpenRecordset "select * from X  where x.Name ='" & replace(nameString, "'", "''") & "'")

Author Comment

ID: 17098923
>>Please give an example of a nameString that causes a problem.

e.g.  'Thi'sIsInFrench'
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17098932
Then my suggestion applies.

Author Comment

ID: 17099141
I have heard that it is possible to submit an sql query with user defined delimiters
1) [An SQL command which defines '$' to be my string delimiter]
2) a select query such as select * from X  where x.Name =$asd""rewrq''fgfds$, which would process the quotes as just another character.  can you give me some advice as per 1 above.

LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17099327
This is not possible in MSSQL Server.

Author Comment

ID: 17099369
Thanks for the answer.

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Trigger C# code inside the SQL Server 6 36
SQL Syntax 6 33
How to add an Index to a date/time field? 15 15
SQL Help 4 19
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question