Solved

Help! Search string using ADO and SQL

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

746 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

13 Experts available now in Live!

Get 1:1 Help Now