Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL LIKE operator with ADO vs. DAO

Status
Not open for further replies.

colobill

Programmer
Dec 16, 2003
22
US
I have a program where I initially used an ADO data control with a grid. When I used a SQL LIKE operator it works and displays the expected data in the grid. Because of the end user (i.e., '98, ME, etc.) I cannot use the ADO data controls because info does not show up on the grid. So, when I use the same exact SQL string:

strSQL = "SELECT * FROM SLPT WHERE DESCRIPTION LIKE '" & "%" & searchword & "%" & "'"
Data1.DatabaseName = (App.Path & "\ELPALS.mdb")
Data1.RecordSource = strSQL
Data1.Refresh


with a DAO data control (the default one that comes with VB 6), I cannot get any data to show on the grid.

Does any one have any suggestions? I would like to go with just ADO statements but Windows ME does not respond to them well.
 

Q., On this target machine did you create an install package for it and install the program?

A., If not then create an install package and install the program.

Good Luck

 
This is on my development computer. There seems to be some subtleties between ADO and DAO and what you get from SQL statements such as using the LIKE command. I cannot get the LIKE operator working with DAO.
 
Never mind. I figure it out. In the sql string of:

strSQL = "SELECT * FROM SLPT WHERE DESCRIPTION LIKE '" & "%" & searchword & "%" & "'"

DAO apparently does not like %. I substituted asterisks "*" instead and it worked.
 
For reference the % sign is used as the LIKE operator for SQL Server, when using an access mdb you need to use the * operator. I think ADO is smart enough to recognize and handle the difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top