Solved

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

Posted on 2006-07-13
7
254 Views
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.
0
Comment
Question by:yossikally
  • 3
  • 3
7 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Hi yossikally,

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

Regards,

Patrick
0
 
LVL 142

Accepted Solution

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

Author Comment

by:yossikally
Comment Utility
>>Please give an example of a nameString that causes a problem.

e.g.  'Thi'sIsInFrench'
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
Then my suggestion applies.
0
 

Author Comment

by:yossikally
Comment Utility
I have heard that it is possible to submit an sql query with user defined delimiters
e.g.
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.

10x
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
This is not possible in MSSQL Server.
0
 

Author Comment

by:yossikally
Comment Utility
Thanks for the answer.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now