Subject |
Re: Paremeter for SQL SELECT |
From |
Svatopluk Blaha <svatopluk.blaha@seznam.cz> |
Date |
Fri, 27 Mar 2015 07:47:00 -0400 |
Newsgroups |
dbase.getting-started |
Mervyn Bick Wrote:
> On Thu, 26 Mar 2015 15:05:43 +0200, Svatopluk Blaha
> <svatopluk.blaha@seznam.cz> wrote:
>
>
> > Many thanks for explaining but using your's code I do not obtain asked
> > result. Table Job has fields Id and Xy, value of Id are "A" or "B".
> > Formular has an entryfield for input parameter value and a pushbutton
> > for starting selection. The code I have is:
> > ....
>
> > function PUSHBUTTON1_onClick
> > cId = form.entryfield1.value // cId = "A"
> > ? "cId= "+cId
> > q = new Query()
> > q.sql=[SELECT * FROM Job WHERE Id = :pId]
> > q.params['pId'] = 'cId'
> > q.requestLive := false
> > q.active:=true
> > return
> >
> > No result. Single statement: SELECT * FROM Job WHERE Id = 'A' works as
> > it is expected of course. Where i made a mistake?
>
> The problem is q.params['pId'] = 'cId'
>
> You are asking dBASE to select records where the string "cId" is found in
> the Id field and, of course, there aren't any. If you remove the quote
> marks all should be well.
>
> You will also probably need to trim the value in entryfield1. It is also
> probably a good idea to force the value in entryfield1 to uppercase to
> match the values in the table just in case the user enters a lowercase
> value.
>
> cId = upper(trim(form.entryfield1.value))
>
> q.params['pId'] = cId
>
>
> This will look for records where Id holds the contents of cId which, in
> this case, is "A".
>
>
> Mervyn.
Svatopluk Blaha wrote:
I used it, but no result. I expect from this code the same result as from the sigle SQL statement (writen above): the table with records which hold value "A" in the fileld Id. I do'nt obtain it.
Best Regards
Svatopluk Blaha
|
|