• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • 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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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