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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

queries in code vs. query wizard 1

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have a query that I'm running through my code. In my form when the code is run it returns no results. When I copy the same query into the sql query builder it returns results. What's wrong?
Here's my query
SELECT distinct company.company_id, Company.Com_Name, c.nc, Company.Country_ID FROM c INNER JOIN Company ON c.c=Company.Country_ID where ( com_name like "*test*") order BY Company.Com_Name

I find that it's not returning results when it uses the operator like and *
 
One direction I am thinking on is the syntaxis. The syntaxis in code is slightly different from the code you use in the query builder. How is the SQL statement in your code ? Can you send it.

Pat.
 
This IS the exact sql statement used for both. I copied and pasted from one to the other
 
They should be different, like :


strSQL = "SELECT [T-01-FIRM-FEATURE].FEATURE " _
& "FROM ([T-02-CONTACT] INNER JOIN [T-01-ENTERPRISE] ON [T-02-CONTACT].[C-refFIRM] = [T-01-ENTERPRISE].[ID-FIRM]) INNER JOIN [T-01-FIRM-FEATURE] ON [T-01-ENTERPRISE].refFEATURE = [T-01-FIRM-FEATURE].IDF " _
& "WHERE ((([T-02-CONTACT].[C-MAIL]) Is Not Null)); "

where :
" start your SQL Statement
" _ end a line
& " start the next line
; " terminate your SQL Statement at the end

try :
for (com_name like "*test*") try (com_name like '*test*') or try (com_name like ""*test*"")

regards, pat.




 
what do you mean by "code"...are you using ADO ? ie 'who' is compiling the query?

if ado then replace * with %

Cheers,
Dan
 
Thank You! - I was using ado
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top