Ok I know I’m probably missing something very simple but I need help!
Basically I’m trying to get this search function to work with my flash. When you type a value in flash and the asp outputs the results. Flash then pulls the results and displays them. This just has to work with duplicate results (such as 2 ppl with the same last name).
I can get the search function to work however it only pulls one record not all matching ones.
Sorry if I sound like a muppet, I’m a bit green to ASP. Please help!
<[email="%@Language="]%@Language="VBScript"%[/email]>
<%
Dim employees
Dim oConn
Set employees = Server.CreateObject("ADODB.Recordset")
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.ConnectionString = "AllAsText=0;ApplicationUsingThreads=1;Driver=FileMaker Pro;FetchChunkSize=100;FileOpenCache=0;IntlSort=0; MaxTextlength=255;ServerAddress=127.0.0.1;TranslationOption=0;UseRemoteConnection=1" & Server.MapPath("employees.fp5")
oConn.Open
employees.Open "SELECT * FROM Employees", oConn, 2, 3
employees.Find "NameLast = '" & UCase(Request.QueryString("strSearch")) & "'"
If employees.EOF Then
Response.Write "NameLast=Not+Found&NameFirst=Not+Found&Position=Not+Found"
Else
Response.Write "NameFirst=" & Server.URLEncode(employees("NameFirst")) & "&NameLast=" & Server.URLEncode(employees("NameLast")) & "&Position=" & Server.URLEncode(employees("Position"))
End If
find = UCase(Request.QueryString(“strSearch”))
employees.Open “SELECT * FROM Employees WHERE NameLast=’”& find &"’", oConn, 2, 3
If employees.EOF Then
Response.Write “NOT FOUND”
Else
[COLOR=Red] employees.MoveFirst()
do while Not(employees.EOF)[/COLOR]
Response.Write “NameFirst=” & Server.URLEncode(employees(“NameFirst”)) & “&NameLast=” & Server.URLEncode(employees(“NameLast”)) & “&Position=” & Server.URLEncode(employees(“Position”))
[COLOR=Red] employees.MoveNext()
loop[/COLOR]
End If
%>
You have to give some instruction to the recordset, your code was doing what it should it should be displaying one record. You have to add the code in red for it to go through the recordset and display the rest of the records.
good site for more ASP tips & hints if the w3schools
Thanks for your help RabBell, I was able to fix my problem with a little bit of recoding. Had to change my SQL statement like you said and put in a different loop.
Dim employees, oConn, lname, sqlString
lname = request.QueryString("strSearch")
sqlString = "SELECT * FROM Employees where NameLast = '" & lname & "'"
Set employees = Server.CreateObject("ADODB.Recordset")
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.ConnectionString = "AllAsText=0;ApplicationUsingThreads=1;Driver=FileMaker Pro;FetchChunkSize=100;FileOpenCache=0;IntlSort=0; MaxTextlength=255;ServerAddress=127.0.0.1;TranslationOption=0;UseRemoteConnection=1" & Server.MapPath("employees.fp5")
oConn.Open
employees.Open sqlString, oConn, 2, 3
If employees.EOF then
Response.Write "NOT FOUND"
Else
while not (employees.eof)
Response.Write "&NameFirst=" & Server.URLEncode(employees("NameFirst")) & "&NameLast=" & Server.URLEncode(employees("NameLast")) & "&Position=" & Server.URLEncode(employees("Position"))
employees.movenext
wend
End If
My next question is that I am able to display the results in a dynamic text field in flash. However, I need to the results to be clickable and unique. So if theres 2 smiths that show up in the results, the user can select the correct smith and the information specific to that record shows up.