04-18-2008, 02:11 AM
;I have a problem with an Access Query using a variable in the Query string.
;For a simple Access Database:
;ID Date ALT AST
;1 2/2/2008 100 110
;2 3/15/2008 200 210
;3 4/1/2008 300 310
Database db2.Open(db2.CsAccess("$personal$\AccessFiles\mydb1.mdb"))
ARRAY(str) a
int r c
;I want to query with Date as a variable:
DATE d="4/1/2008"
;But this does not work for me:
db2.QueryArr("SELECT ALT FROM Table1 WHERE Date = d" a)
for r 0 a.len(2)
,out "--Record %i--" r+1
,for c 0 a.len(1)
,,out a[c r]
,,
,,
;The following code works fine when Date is not sent as a variable:
Database db2.Open(db2.CsAccess("$personal$\AccessFiles\mydb1.mdb"))
ARRAY(str) a
int r c
db2.QueryArr("SELECT ALT FROM Table1 WHERE Date = #4/1/2008#" a)
for r 0 a.len(2)
,out "--Record %i--" r+1
,for c 0 a.len(1)
,,out a[c r]
;How can I send a Variable in the query?
,,
;For a simple Access Database:
;ID Date ALT AST
;1 2/2/2008 100 110
;2 3/15/2008 200 210
;3 4/1/2008 300 310
Database db2.Open(db2.CsAccess("$personal$\AccessFiles\mydb1.mdb"))
ARRAY(str) a
int r c
;I want to query with Date as a variable:
DATE d="4/1/2008"
;But this does not work for me:
db2.QueryArr("SELECT ALT FROM Table1 WHERE Date = d" a)
for r 0 a.len(2)
,out "--Record %i--" r+1
,for c 0 a.len(1)
,,out a[c r]
,,
,,
;The following code works fine when Date is not sent as a variable:
Database db2.Open(db2.CsAccess("$personal$\AccessFiles\mydb1.mdb"))
ARRAY(str) a
int r c
db2.QueryArr("SELECT ALT FROM Table1 WHERE Date = #4/1/2008#" a)
for r 0 a.len(2)
,out "--Record %i--" r+1
,for c 0 a.len(1)
,,out a[c r]
;How can I send a Variable in the query?
,,