Page 1 of 1

Syntax to use variable in a query using PB API & SQLite

Posted: Wed Apr 23, 2008 12:04 pm
by Pierre Mercier
I am just starting programming in Pure Basic and i can't find the right syntax for queries using variable and passing it from PB api to SQLite database

All Samples below is use on a program done with VB6 and MSAccess and all :shock: work properly

Here is a sample of different small queries using different variable

Using a String var
"SELECT Client.* FROM client WHERE ((Client.ville) = ' " & MyCity & " '))

Using a numeric var
"SELECT Client.* FROM client WHERE ((Client.Zipcode) = " & MyZipCode & "));"

Using a string var and a numeric var and formattinf the query on 2 lines for easy reading
"SELECT Client.* FROM Client WHERE (((Client .ville) = ' " & MyCity & " ') " _
& "AND ((client.CP) =(" & MyCP & "))

Using a string var with like operator
"SELECT Client.* FROM Client WHERE (((Client.CP) like '*" & MyCP & *');"

Using a Datetime Var
"SELECT Client.* FROM Client WHERE (((Client.Dlv) = #" & MyDate & "# ))

Posted: Wed Apr 23, 2008 12:33 pm
by rsts
Quite a few of us use a 'wrapper'.

See if this helps http://www.purebasic.fr/english/viewtopic.php?t=27036

search may also help. report back if it doesn't.

cheers

Posted: Wed Apr 23, 2008 2:17 pm
by Num3
well i think i know what you need is:

Code: Select all

"Select * FROM Client WHERE ville='"+Mycity+"'"

Queries's syntax

Posted: Thu Apr 24, 2008 1:04 pm
by Pierre Mercier
That exactly what i need and it work perfectly on string. I will try the
other with + replacing &.

Many thank's :P