Set aspdbweb = Server.CreateObject("ADODB.Connection") aspdbweb = "Provider=Microsoft.Jet.OLEDB.4.0; " _ & Data Source=" & Server.MapPath("employees.mdb") & ";"
' WHERE 1=1 is sneaky trick so we can use AND for other conditions SQL = "SELECT * FROM Employees WHERE 1=1 "
' the REPLACE calls are to protect against SQL injection whatToSearch = Replace( Trim( Request("ASPDBCatSearch") ), "'", "''" ) keyword = Replace( Trim( Request("Keyword") ), "'", "''" )
If whatToSearch <> "All" Then SQL = SQL & " AND " & whatToSearch & " LIKE '%" & keyword & "%' " End If
salary = Replace( Trim( Request("SalaryCom") ), "'", "''" ) If salary <> "" Then SQL = SQL & " AND salary " & salary End If
SQL = SQL & " ORDER BY LastName, FirstName " ' or whatever order you want
' don't use a static cursor when you don't need it...simpler & faster: Set rsglobal = aspdbweb.Execute( SQL ) If rsglobal.EOF Then %> <h2 align="center">We did not find a match!</h2> <% Else %> <h2>Here are the results of your search:</h2>
... rest same ...
*********************
*NEVER* bother checking BOF. Pointless.
You can change the VALUE='s for salary to match what you mean if I didn't guess right.
... unless navigation in the recordset has occurred, or records have been deleted from it.
If you had added " ... immediately after opening the recordset." I would have had no comment. -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.