|
pog Newbie
Joined: 17 Nov 2005 Posts: 2
|
Posted: Thu Nov 17, 2005 2:10 pm
Problem with LIKE in ADO SQL command |
Hi,
I wonder if anyone can help me. I've recently set up a database in Access2000 format for storing SWs etc. Using ADO I can link to the database fine and retrieve info.
I've tried to add LIKE to my SQL command, but no records are returned - however if I c&p the SQL command into access it works fine. Any ideas what I can do to fix it?
An example SQL command:
SELECT * FROM qryAreaSWs WHERE AREA_NAME LIKE 'A*'
and the code that creates/exectues it:
#VAR Conn %comcreate( "ADODB.Connection")
#CALL @Conn.Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\zmud\aardwolf\DB\tip.mdb")
#VAR SQL "SELECT * FROM qryAreaSWs WHERE AREA_NAME LIKE '%1*'"
#ECHO Debug: Sql = @SQL
#VAR rs @Conn.Execute(@SQL)
#IF @rs.Eof {#ECHO No matching SWs found} {#ECHO @rs.GetString}
#CALL @rs.Close
#VAR rs ""
#VAR Conn ""
rs.Eof is always True after the Conn.Execute, even though running the same SQL command in Access returns a whole host of records.
Any help is appreciated.
Thanks,
Pog |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
|
|
|
pog Newbie
Joined: 17 Nov 2005 Posts: 2
|
Posted: Thu Nov 17, 2005 10:53 pm |
Thanks for that.
Noticed on the very last note that you were using LIKE % rather than LIKE *.
Even though access was happy with the SQL statement "SELECT * FROM qryAreaSWs WHERE AREA_NAME LIKE '%1*'"
it needs to be "SELECT * FROM qryAreaSWs WHERE AREA_NAME LIKE '%1%'" from within zMud.
Problem solved, and I'm happy :)
Once again, thanks for the tip. |
|
|
|
|
|