Solved

Help! Search string using ADO and SQL

Posted on 2000-05-11
4
144 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

825 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