Here is my full coding:
Here is my code:
<%
Dim MyConn, SQL, RS campus, title, A,B
A = "Receptionist"
B = "Data Entry"
campus = request.form("campus")
title = request.form("title")
If title = "A" Then
A = "Receptionist"
Elseif title = "A" Then
A = "Customer service Assitance"
Elseif title = "A" Then
A = "Front Desk Clerk"
End If
If title = "B" Then
B = "Data Entry"
Elseif title = "B" Then
B = "Computer Operator"
End If
SQL = "Select campus, title, hours from Mytable where campus Like '"&%campus%&"' And title Like '"&%title%&"'"
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "MyConnection"
Set RS = Server.Createobject("Adodb.Recordset")
Set RS=MyConn.Execute (sql)
Response.Write "<center><table border=""0"" width='50%'>"
If RS.EOF Then
Response.write "No records were found for : "
Response.write"<font color=""cc3300"">"
Response.write campus & "," & title
Response.write"</font>"
Else
Do While Not RS.EOF
Response.write"<tr bgcolor=silver >"
Response.write "<td >" & RS("campus") & "</td>"
Response.write"<td >" & RS("title") & "</td>"
Response.write"<td >" & RS("hours") & "</td>"
Response.write"</tr>"
RS.Movenext
Loop
RS.Close
Response.write "</table>"
End If
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
%>
The above code is search page code which searches the dept table to find the information. The dept table have all detailed information such as Receptionist, Customer Service Assistant, and Front Desk Assistant. But the search criteria in search page has only Receptionist in the drop down list, which it should be able to pull all records from the dept table related to receptionist. That is why I am doing a Select Case or even if statement to let program know that it has to pull. I am kind of stuck in that part.
In your example, "select * mytable where (1=1)" what does 1=1 do?
Code:
strSQL = "SELECT * MyTable WHERE (1=1)"
If Rep <> "" Then
strSQL = strSQL & " AND (Rep='" & Rep & "')"
End If
If Customer <> "" Then
strSQL = strSQL & " AND (Customer='" & Customer & "')"
End If
By looking at my code, can you please tell how I can improve my coding in order to do the stuff I want to do.