Article View: borland.public.intrabuilder.data.sql
Article #87Problem with MS Access Query & ODBC
From: Kern Weissman
Date: Fri, 04 Sep 1998 00:00
Date: Fri, 04 Sep 1998 00:00
57 lines
2526 bytes
2526 bytes
I am continuing to have problems passing the below expression utilizing
the "LIKE" operator to MS Access97
When using Borland's Intrabuilder with JavaScript.
The problem is to match a string to the first five characters of a text
field containing zip codes of varying lengths. The following SQL code
when used directly in Access works with no problem. When run it
identifies the record with a six digit zip code "M8Z5T5" by matching the
first five characters.
SELECT metatec.vchr_number, metatec.cust_code, metatec.dzip
FROM metatec
WHERE (((metatec.vchr_number)="C001138") AND
((metatec.cust_code)>="2294000" And (metatec.cust_code)<="2294999") AND
("M8Z5T" LIKE "*" + left((metatec.dzip),5) + "*"));
When I attempted to run it in a form in the intrabuilder as follows, I
received the below error.
form.hidden_Statement.value += "CUST_CODE>='"+name1+"' AND
CUST_CODE<='"+name2+"' AND ('"+name.substring(0,5)+"' LIKE "*" +
left(DZIP,5) + "*" )" ;
}else
Error: Cannot automatically convert data type. The required type is:
Numeric
Removing the asterisks, and using a slightly different syntax caused
this error message. Note there is a typo in the error message "alike"
for "like"
form.hidden_Statement.value += "CUST_CODE>='"+name1+"' AND
CUST_CODE<='"+name2+"' AND '"+name.substring(0,5)+"' LIKE LEFT(DZIP,5)
";
}else
Server Error: [Microsoft][ODBC Microsoft Access 97 Driver] Expression
cannot be
used with the LIKE predicate. in query expression'(VCHR_NUMBER=
'C001138' AND
CUST_CODE>='2294000' AND CUST_CODE<='2294999' AND 'M8Z5T' alike
LEFT(DZIP,5)
)'.
Using slightly different syntax in the form, I got this error.
Server Error: [Microsoft][ODBC Microsoft Access 97 Driver] Expression
cannot be used with the LIKE predicate. in query
expression'(VCHR_NUMBER= 'C001841' AND CUST_CODE>='2294000' AND
CUST_CODE<='2294999' AND ('60188' alike left((DZIP),5) ))'.
Any help would be appreciated
Larry Weissman
larrywm@compuserve.com
Technical Details
Message-ID:
<35EF73AB.3943CD0B@sureway.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 101d9a,5d76e7e24001dbeb,start X-Google-Attributes: gid101d9a,public From: Kern Weissman <kweissman@sureway.net> Subject: Problem with MS Access Query & ODBC Date: 1998/09/04 Message-ID: <35EF73AB.3943CD0B@sureway.net> X-Deja-AN: 387729807 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.intrabuilder.data.sql