Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: WHERE statement


Message #1 by "Enzo Zaragoza" <enzo@r...> on Thu, 29 Mar 2001 15:20:12
Hello everyone!!!



   I'm enzo, I'm just new on ASP & SQL programming, so I hope you can bare 

with me coz I have a lot of questions in the near future =) thanks in 

advance!!!!



   I have a problem regarding SQL statement using WHERE here is my code:





Dim rs As Recordset

Dim db As Database

Dim ss As String

Dim EstimateNum



Set db = CurrentDb



'this is my SQL query wherein EstimateNum is a variable

ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE 

EstimateNo = EstimateNum;"



Set rs = db.OpenRecordset(ss, dbOpenDynaset)



.

.

.

rs.Close



    My problem is how can I put a variable in a WHERE statement instead of 

using: SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE 

EstimateNo = 1; for example.



Help me please!! thanks



Enzo



Message #2 by "Blake, Shane" <Shane.Blake@p...> on Thu, 29 Mar 2001 09:36:04 -0500
Dim EstimateNum

EstimateNum = 1



Set db = CurrentDb



ss = "SELECT ... WHERE EstimateNo = " & EstimateNum



shane

Message #3 by "Frank Klaczik" <fklaczik@c...> on Thu, 29 Mar 2001 15:40:17
Try this:



Dim EstimateNum, ss



EstimateNum = 1



'~~~~your other code~~~~~~~



ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE 

EstimateNo = " & EstimateNum



'~~~~your other code~~~~~~~





> Hello everyone!!!

> 

>    I'm enzo, I'm just new on ASP & SQL programming, so I hope you can 

bare 

> with me coz I have a lot of questions in the near future =) thanks in 

> advance!!!!

> 

>    I have a problem regarding SQL statement using WHERE here is my code:

> 

> 

> Dim rs As Recordset

> Dim db As Database

> Dim ss As String

> Dim EstimateNum

> 

> Set db = CurrentDb

> 

> 'this is my SQL query wherein EstimateNum is a variable

> ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE 

> EstimateNo = EstimateNum;"

> 

> Set rs = db.OpenRecordset(ss, dbOpenDynaset)

> 

> .

> .

> .

> rs.Close

> 

>     My problem is how can I put a variable in a WHERE statement instead 

of 

> using: SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE 

> EstimateNo = 1; for example.

> 

> Help me please!! thanks

> 

> Enzo

> 

Message #4 by "Tomm Matthis" <matthis@b...> on Thu, 29 Mar 2001 11:22:10 -0500
Ciao Enzo!



Try this:



ss =3D "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE 

EstimateNo =3D " & varforEstimateNum & ";"





Tomm



> -----Original Message-----

> From: Enzo Zaragoza [mailto:enzo@r...]

> Sent: Thursday, March 29, 2001 3:20 PM

> To: ASP Databases

> Subject: [asp_databases] WHERE statement

>

>

> Hello everyone!!!

>

>    I'm enzo, I'm just new on ASP & SQL programming, so I hope you

> can bare

> with me coz I have a lot of questions in the near future =3D) thanks 

in

> advance!!!!

>

>    I have a problem regarding SQL statement using WHERE here is my 

code:

>

>

> Dim rs As Recordset

> Dim db As Database

> Dim ss As String

> Dim EstimateNum

>

> Set db =3D CurrentDb

>

> 'this is my SQL query wherein EstimateNum is a variable

> ss =3D "SELECT EstimateNo, ProjectName FROM tblProjectInformation 

WHERE

> EstimateNo =3D EstimateNum;"

>

> Set rs =3D db.OpenRecordset(ss, dbOpenDynaset)

>

> .

> .

> .

> rs.Close

>

>     My problem is how can I put a variable in a WHERE statement

> instead of

> using: SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE 



> EstimateNo =3D 1; for example.

>

> Help me please!! thanks

>

> Enzo

>

>

> ---

Message #5 by "Daniel O'Dorisio" <dodorisio@h...> on Thu, 29 Mar 2001 12:05:16 -0500
for some reason i always do it like this..



Dim EstimateNum

EstimateNum = 1

"SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo='" & EstimateNum & "'"



i dont know if there is a performance difference or anything.. i just never

have any luck any other way:-)



Daniel



-----Original Message-----

From: Enzo Zaragoza [mailto:enzo@r...]

Sent: Thursday, March 29, 2001 3:20 PM

To: ASP Databases

Subject: [asp_databases] WHERE statement





Hello everyone!!!



   I'm enzo, I'm just new on ASP & SQL programming, so I hope you can bare

with me coz I have a lot of questions in the near future =) thanks in

advance!!!!



   I have a problem regarding SQL statement using WHERE here is my code:





Dim rs As Recordset

Dim db As Database

Dim ss As String

Dim EstimateNum



Set db = CurrentDb



'this is my SQL query wherein EstimateNum is a variable

ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo = EstimateNum;"



Set rs = db.OpenRecordset(ss, dbOpenDynaset)



.

.

.

rs.Close



    My problem is how can I put a variable in a WHERE statement instead of

using: SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo = 1; for example.



Help me please!! thanks



Enzo

Message #6 by "e | n | z | o" <enzo@r...> on Fri, 30 Mar 2001 02:14:16 +0800
for some reason i always do it like this..



Dim EstimateNum

EstimateNum =3D 1

"SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo=3D'" & EstimateNum & "'"



i dont know if there is a performance difference or anything.. i just nev

er

have any luck any other way:-)



Daniel



-----Original Message-----

From: Enzo Zaragoza [mailto:enzo@r...]

Sent: Thursday, March 29, 2001 3:20 PM

To: ASP Databases

Subject: [asp_databases] WHERE statement





Hello everyone!!!



I'm enzo, I'm just new on ASP & SQL programming, so I hope you can bare

with me coz I have a lot of questions in the near future =3D) thanks in

advance!!!!



I have a problem regarding SQL statement using WHERE here is my code:





Dim rs As Recordset

Dim db As Database

Dim ss As String

Dim EstimateNum



Set db =3D CurrentDb



'this is my SQL query wherein EstimateNum is a variable

ss =3D "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo =3D EstimateNum;"



Set rs =3D db.OpenRecordset(ss, dbOpenDynaset)



=2E

=2E.

=2E.

rs.Close



My problem is how can I put a variable in a WHERE statement instead of

using: SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo =3D 1; for example.



Help me please!! thanks



Enzo

Message #7 by "Vince Kavanagh" <vince@6...> on Thu, 29 Mar 2001 19:06:17 +0100
For numbers you would use:



ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo = " &  EstimateNum



For strings (text fields in database) you would use:



ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo = '" &  EstimateNum & "'"





If you find your SQL statements overshoot the page you can split them with

either:



ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE" _

& " EstimateNo = '" &  EstimateNum & "'"



OR



ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE"

ss = ss & " EstimateNo = '" &  EstimateNum & "'"



Best Regards,



Vince.





-----Original Message-----

From: Enzo Zaragoza [mailto:enzo@r...]

Sent: 29 March 2001 15:20

To: ASP Databases

Subject: [asp_databases] WHERE statement





Hello everyone!!!



   I'm enzo, I'm just new on ASP & SQL programming, so I hope you can bare

with me coz I have a lot of questions in the near future =) thanks in

advance!!!!



   I have a problem regarding SQL statement using WHERE here is my code:





Dim rs As Recordset

Dim db As Database

Dim ss As String

Dim EstimateNum



Set db = CurrentDb



'this is my SQL query wherein EstimateNum is a variable

ss = "SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo = EstimateNum;"



Set rs = db.OpenRecordset(ss, dbOpenDynaset)



.

.

.

rs.Close



    My problem is how can I put a variable in a WHERE statement instead of

using: SELECT EstimateNo, ProjectName FROM tblProjectInformation WHERE

EstimateNo = 1; for example.



Help me please!! thanks



Enzo





---


  Return to Index