Solved

Help! Search string using ADO and SQL

Posted on 2000-05-11
4
145 Views
Last Modified: 2010-05-02
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
Comment
Question by:mrxz
[X]
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
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
Marine earned 10 total points
ID: 2800540
   Rst.Open "SELECT * FROM Company WHERE Company = '" & Replace(ltCompany.Text),"'","''") & "'"
0
 
LVL 1

Expert Comment

by:simonstre
ID: 2800614
you must double the ' in Wordld's Company, in order to make the string looks like that :  "Worlds''s company"

0
 
LVL 1

Expert Comment

by:simonstre
ID: 2800617
sorry for the mistakes :-) I meant "World''s company"
0
 

Author Comment

by:mrxz
ID: 2800692
Thanks for help!
The syntax had an extra ")" closing the replace command.
But fits very well
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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