Added: July/06/2004 at 1:17am | IP Logged
|
|
|
Example on a page receiving a post of a SQL statement based on two listboxes (MyCategory and MyLocation) that might each have a value of "" (i.e. blank) to show all with no criteria restrictions.
' Dim var. Dim MyCategory Dim MyLocation
' Get posted form vars. MyCategory = Request.Form("MyCategory") MyLocation = Request.Form("MyLocation")
' Set strSQL. strSQL = "SELECT * MyTable WHERE (1=1)" If MyCategory <> "" Then strSQL = strSQL & " AND (MyCategory='" & MyCategory & "')" End If If MyLocation <> "" Then strSQL = strSQL & " AND (MyLocation='" & MyLocation & "')" End If
__________________ J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
|