Query/Search MS Access database using Flash and .A
hotflash | Posted 10:30am 20. November 2007 Server Time |
Hi All,
I have a Flash MX contact form that has the following fields: First Name, Last Name, Phone Number, Email, and Comments along with the search box and button. What I would like to do is to put in the ContactID (record number generated by MS Access) in the Search box, once the Search button is hit, it will display the First Name, Last Name, Phone Number, Email and Comments associate to the ContactID (record #).
This is how I defined in Flash MX.
First Name, Last Name, Phone Number, Email and Comments as Dynamic Text with the Variables of FirstName, LastName, PhoneNumber, Email and Comments respectively.
The Search box is defined as Input text with the Variable of myrecord. The actionscript for the Search button defined as follow:
on (release) {
loadVariablesNum("http://yourwebsite/GDNICF/cinformation/QueryContacts.asp?Record=" add myrecord, 0);
myrecord="";
FirstName="";
LastName="";
PhoneNumber="";
Email="";
Comments="";
Message="Search .... Please wait";
}
Also, here is my QueryContacts.asp:
<%
'Pass the ID you got back in the field called record
record=request("Record")
Set objconn=server.createobject("adodb.connection")
objconn.open "provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("AddContacts.mdb")
set objrecord=server.createobject("adodb.recordset")
sql="select * from Contacts where ContactID =" & record
objrecord.Open sql,objconn
if objrecord.eof then
Response.Write "Record Not Found "
'response.end
else
FirstName= server.URLEncode(objrecord.fields("FirstName"))
LastName= server.URLEncode(objrecord.fields("LastName"))
PhoneNumber= server.URLEncode(objrecord.fields("PhoneNumber"))
Email= server.URLEncode(objrecord.fields("Email"))
Comments= server.urlencode(objrecord.fields("Comments"))
Response.Write "First Name - " & FirstName & "<BR>"
Response.Write "Last Name - " & LastName & "<BR>"
Response.Write "Phone Number - " & PhoneNumber & "<BR>"
Response.Write "Email - " & Email & "<BR>"
Response.Write "Comments - " & Comments & "<BR>"
end if
%>
Please help. Thanks. |