• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Help! Search string using ADO and SQL

Hi!!!
I would like to know if someome can help me to build a search string using ADO 2.1 , VB 6.0 and MS SQL 6.5 / 7.0.

I built this string:
    Rst.Open "SELECT * FROM Company WHERE Company = '" & ltCompany.Text & "'"

It works almost OK, but fail when I try to search for "World's Company"

with the following error:
ERROR  -2147217900(80040E14)

Thanks for any help
Regards,
Mrxz
0
mrxz
Asked:
mrxz
  • 2
1 Solution
 
MarineCommented:
   Rst.Open "SELECT * FROM Company WHERE Company = '" & Replace(ltCompany.Text),"'","''") & "'"
0
 
simonstreCommented:
you must double the ' in Wordld's Company, in order to make the string looks like that :  "Worlds''s company"

0
 
simonstreCommented:
sorry for the mistakes :-) I meant "World''s company"
0
 
mrxzAuthor Commented:
Thanks for help!
The syntax had an extra ")" closing the replace command.
But fits very well
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now