Hi,
I am having so many problems trying to do a seemingly simple thing. This ASP code is supposed to find record(s) in the access database with a certain last name and then pass the respective first names to Flash as an array. Please take a look at the code and see if you can help.
In case you are wondering, this is (for now) going to be used to lookup student information. The reason why I am going through the trouble of using the loop and the array is because many students have the same last name and I want all of the students with the same last name to show up instead of just the first record. Also, like I said, this is passing variables to a flash (.swf) file that I have in the same directory.
I am having so many problems trying to do a seemingly simple thing. This ASP code is supposed to find record(s) in the access database with a certain last name and then pass the respective first names to Flash as an array. Please take a look at the code and see if you can help.
Code:
Dim oRS, oConn, oRS2, counter, numberrecords
Set oRS = Server.CreateObject("ADODB.Recordset")
Set oRS2 = Server.CreateObject("ADODB.Recordset")
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database.mdb")
oRS2.Open "SELECT Count(*) AS intTotal FROM tblUsers WHERE LastName='" & Request.QueryString("lastnamesearch") & "'", oConn, 2, 3
oRS.Open "SELECT * FROM tblUsers WHERE LastName='" & Request.QueryString("lastnamesearch") & "'", oConn, 2, 3
numberrecords=oRS2("intTotal")
counter=1
Response.Write "numberrecords=" & oRS2("intTotal")
if NOT oRS.EOF then
[COLOR=red]For counter = 1 to numberrecords
Response.Write "&thisarray[" & counter & "]=" & oRS("FirstName")
oRS.MoveNext
Next[/color]
end if
If oRS.EOF Then
Response.Write "&firstname=Not+Found&lastname=Not+Found&grade=Not+Found"
Else
Response.Write "&firstname=" & Server.URLEncode(oRS("FirstName")) & "&lastname=" & Server.URLEncode(oRS("LastName")) & "&grade=" & Server.URLEncode(oRS("Grade"))
End If
oRS.Close
Set oRS = Nothing
oRS2.Close
Set oRS2 = Nothing
oConn.Close
Set oConn = Nothing
In case you are wondering, this is (for now) going to be used to lookup student information. The reason why I am going through the trouble of using the loop and the array is because many students have the same last name and I want all of the students with the same last name to show up instead of just the first record. Also, like I said, this is passing variables to a flash (.swf) file that I have in the same directory.