variables in where clause [message #1068] |
Tue, 26 March 2002 21:35 |
rajesh
Messages: 173 Registered: November 1998
|
Senior Member |
|
|
hi i need some help with where cluase in sql
can i use variables in where clause
like
dim sTemp as string //variable declaration in vb
sTemp="rajesh"
can i use
select * from employee where employee.firstname=sTemp
if i used it the above way it is not working.can some one plz tell me what is the exact syntax.
|
|
|
Re: variables in where clause [message #1074 is a reply to message #1068] |
Wed, 27 March 2002 10:46 |
Marie
Messages: 8 Registered: March 2002
|
Junior Member |
|
|
What I do (using VB also)
dim SQL as string
dim sTemp as string //variable declaration in vb
sTemp="rajesh"
can i use
SQL = "select * from employee where employee.firstname='" & sTemp & "'
then execute the SQL variable, since it contains the sql statement
|
|
|
Re: variables in where clause [message #1082 is a reply to message #1074] |
Thu, 28 March 2002 11:26 |
rajesh
Messages: 173 Registered: November 1998
|
Senior Member |
|
|
hi marie,
i tried the way u suggested but even then it works only if the sTemp variable is a const
like
const sTemp="rajesh"
dim sql as tring
sql="select * from Employee where ename ='"& sTemp &"'"
if i try doing
const sTemp=txtEname.txt
and then
dim sql as tring
sql="select * from Employee where ename ='"& sTemp &"'"
and do
connection.execute sql
it doesnt work
it says it needs constant expressionn in
const sTemp=txtename.txt
____________ (error)
|
|
|