Advertisement

05.02.2004 at 05:01PM PDT, ID: 20975395
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

Get the most recent record ID and pass as a link in CDONTS email

Asked by wcameron in Active Server Pages (ASP)

Tags: , , , ,

I have a form that collects data and passes to an asp page. The ASP page does several things:

1. It assigns form values to fields values
2. It enters the data into a database
3. It accesses a second database to retrive a destinations name from a DestID field value passed from the form.
4. It accesses the database to find the most recent InquiryID submitted by the sender.
5. It sends an email to the site administrator to indicate a new booking
6. It sends an email to the person making the inquiry providing more details.

I would like step 5 to be able to add a link to the email that will open up a page called InquiryDetails.asp that will provide more details about the booking by passing the InquiryID parameter. The InquiryDetails.asp page will be created with FrontPage's Database Results Wizard.

Here is my code:

<%option explicit
dim Title, DestID, FirstName, LastName, OtherNames, PostalCode, Comments, NumberGuests, DestName, _
      ContactTime, City, Daytime, Evening, Cell, Fax, State, Country, Ages, StartDate, dState, _
      EndDate, NumberDays, Email, Activity, Address1, Address2, objConn, strConn, rs, SQLStmt, _
      DestAddress, DestCity, DestState, DestZip, DestCountry, DestTollFree, DestPhone, _
      DestFax, DestWebsite, DestEmail, DestLocation, MaxOfInquiryID, InquiryID,RS2, objConn2, _
      strConn2, SQLStmt2
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<%
'Assign values from the form data
DestID = Request.Form("DestID")
StartDate = Request.Form("StartDate")
EndDate = Request.Form("EndDate")
NumberGuests = Request.Form("NumberGuests")
Ages = Trim(Replace(Request.Form("Ages"),"'", "''"))
Activity = Trim(Replace(Request.Form("Activity"),"'", "''"))
NumberDays = Trim(Replace(Request.Form("NumberDays"),"'", "''"))
Title = Trim(Replace(Request.Form("Title"),"'", "''"))
FirstName = Trim(Replace(Request.Form("FirstName"),"'", "''"))
LastName = Trim(Replace(Request.Form("LastName"),"'", "''"))
OtherNames = Trim(Replace(Request.Form("OtherNames"),"'", "''"))
Address1 = Trim(Replace(Request.Form("Address1"),"'", "''"))
Address2 = Trim(Replace(Request.Form("Address2"),"'", "''"))
City = Trim(Replace(Request.Form("City"),"'", "''"))
State = Trim(Replace(Request.Form("State"),"'", "''"))
Country = Trim(Replace(Request.Form("Country"),"'", "''"))
PostalCode = Trim(Replace(Request.Form("PostalCode"),"'", "''"))
Daytime = Trim(Replace(Request.Form("Daytime"),"'", "''"))
Evening = Trim(Replace(Request.Form("Evening"),"'", "''"))
Cell = Trim(Replace(Request.Form("Cell"),"'", "''"))
Fax = Trim(Replace(Request.Form("Fax"),"'", "''"))
Email = Trim(Replace(Request.Form("Email"),"'", "''"))
ContactTime = Trim(Replace(Request.Form("ContactTime"),"'", "''"))
Comments = Trim(Replace(Request.Form("Comments"),"'", "''"))

'Get the value of the Destination Name to match the DestID
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("../fpdb/Destinations.mdb") & ";"
objConn.Open


SQLStmt = "SELECT * FROM qDestLocations WHERE DestID = " & DestID

Set RS = ObjConn.execute(SQLStmt)
If err.number>0 then
      response.write "VBScript Errors Occurred:" & "<p>"
      response.write "Error Number=" & err.number & "<p>"
      response.write "Error Descr.=" & err.description & "<p>"
      response.write "Help Context=" & err.helpcontext & "<P>"
      response.write "Help Path=" & err.helppath & "<P>"
      response.write "Native Error=" & err.nativeerror & "<P>"
      response.write "Source=" & err.source & "<P>"
      response.write "SQLState=" & err.sqlstate & "<P>"
end if
If objConn.errors.count>0 then
      response.write "Database Errors Occurred" & "<P>"
      response.write SQLStmt & "<P>"
      for counter=0 to objConn.errors.count
      response.write "Error #" & objConn.errors(counter).number & "<P>"
      response.write "Error desc. -> " & objConn.errors(counter).description & "<P>"
next
      else
            Do While Not RS.EOF
            ' This assigns DestLocation to a variable
            DestName = RS("DestName")
            DestLocation = RS("DestLocation")
            DestAddress = RS("Address")
            DestCity = RS("City")
            DestState = RS("State")
            DestZip = RS("ZipCode")
            DestCountry = RS("Country")
            DestTollFree = RS("TollFree")
            DestPhone = RS("Phone")
            DestFax = RS("Fax")
            DestWebsite = RS("Website")
            DestEmail = RS("Email")
            RS.MoveNext
            Loop
end if
objConn.close
set objConn=nothing
set rs=nothing
      %>

<%
'enter the form data into the database
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("../fpdb/Booking.mdb") & ";"
objConn.Open


SQLStmt = "INSERT INTO tBookings(DestID, StartDate, EndDate, NumberGuests, Ages, Activity, NumberDays, Title, FirstName, LastName, OtherNames, Address1, Address2, City, State, Country, PostalCode, Daytime, Evening, Cell ,Fax, Email, ContactTime, Comments)"
SQLStmt = SQLStmt & " values ("
SQLStmt = SQLStmt & "'" & DestID & "', "
SQLStmt = SQLStmt & "'" & StartDate & "', "
SQLStmt = SQLStmt & "'" & EndDate & "', "
SQLStmt = SQLStmt & "'" & NumberGuests & "', "
SQLStmt = SQLStmt & "'" & Ages & "', "
SQLStmt = SQLStmt & "'" & Activity & "', "
SQLStmt = SQLStmt & "'" & NumberDays & "', "
SQLStmt = SQLStmt & "'" & Title & "', "
SQLStmt = SQLStmt & "'" & FirstName & "', "
SQLStmt = SQLStmt & "'" & LastName & "', "
SQLStmt = SQLStmt & "'" & OtherNames & "', "
SQLStmt = SQLStmt & "'" & Address1 & "', "
SQLStmt = SQLStmt & "'" & Address2 & "', "
SQLStmt = SQLStmt & "'" & City & "', "
SQLStmt = SQLStmt & "'" & State & "', "
SQLStmt = SQLStmt & "'" & Country & "', "
SQLStmt = SQLStmt & "'" & PostalCode & "', "
SQLStmt = SQLStmt & "'" & Daytime & "', "
SQLStmt = SQLStmt & "'" & Evening & "', "
SQLStmt = SQLStmt & "'" & Cell & "', "
SQLStmt = SQLStmt & "'" & Fax & "', "
SQLStmt = SQLStmt & "'" & Email & "', "
SQLStmt = SQLStmt & "'" & ContactTime & "', "
SQLStmt = SQLStmt & "'" & Comments & "'"
SQLStmt = SQLStmt & ")"

Set RS = ObjConn.execute(SQLStmt)
If err.number>0 then
response.write "VBScript Errors Occurred:" & "<p>"
response.write "Error Number=" & err.number & "<p>"
response.write "Error Descr.=" & err.description & "<p>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
If objConn.errors.count>0 then
response.write "Database Errors Occurred" & "<P>"
response.write SQLStmt & "<P>"
for counter=0 to objConn.errors.count
response.write "Error #" & objConn.errors(counter).number & "<P>"
response.write "Error desc. -> " & objConn.errors(counter).description & "<P>"
next
else
response.write "<font face='arial'<b>"
response.write "The booking has been recorded. You will receive an email shortly that will give you additional details about your upcoming activity. MountainNature.com works with only the very best activity suppliers. Your satisfaction is our number one concern. If you are in any unsatisfied with our partner suppliers, please feel free to contact us with any questions you may have.</b><P>"
end if

objConn.close
set objConn=nothing
set rs=nothing
      %>
      <%
'Get the most recent InquiryID for this person
Set objConn2 = Server.CreateObject("ADODB.Connection")
objConn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("../fpdb/Booking.mdb") & ";"
objConn2.Open

SQLStmt2 = "SELECT Max(InquiryID) AS MaxOfInquiryID FROM tBookings Having (FirstName = FirstName) AND (LastName = LastName) AND (DestID = DestID)"
Set RS2 = ObjConn2.execute(SQLStmt2)
      Do While Not RS2.EOF
            InquiryID = RS2("MaxOfInquiryID")
            RS2.MoveNext
      Loop
objConn2.close
set objConn2=nothing
set rs2=nothing

'Send a message to the Site Administrator
Dim MyMail
Set MyMail = CreateObject("CDONTS.NewMail")
MyMail.From= Request.Form("Email")
MyMail.To= "info@mountainnature.com"
MyMail.Subject="New Tour Booking at MountainNature.com"
MyMail.Body = "There is a new booking at Mountainnature.com. " _
      & chr(13) & chr(13) & "Destination: " & DestLocation & ", " & dState & chr(13) & "Activity: " _
      & Activity & chr(13) & "Name: " & FirstName _
      & " " & LastName & chr(13) & "Other Participants: " _
      & OtherNames & chr(13) & "Address Line 1: " _
      & Address1 & chr(13) & "Address Line 2: " & Address2 _
      & chr(13) & "City: " & City & chr(13) & "Province/State: " & State _
      & chr(13) & "Country: " & Country & chr(13) & "Postal/Zip Code: " _
      & PostalCode & chr(13) & "Daytime Phone: " & Daytime  & chr(13) _
      & "Evening Phone: " & Evening  & chr(13) & "Fax: " & Fax  & chr(13) _
      & "Cell Phone: " & Cell & chr(13) & chr(13) & "Details: " & Comments
MyMail.Send
set MyMail=nothing
%>

<%
'Send a message to the person making the inquiry
Dim MyMail2
Set MyMail2 = CreateObject("CDONTS.NewMail")
MyMail2.From= "info@mountainnature.com"
MyMail2.To= request.form("Email")
MyMail2.Subject="Thank you for your tour inquiry"
MyMail2.Body = "Thank you so much for your interest in taking part in a " _
      & Request.Form("Activity") & " in " & DestLocation & ". Here is a summary of what you requested:" _
      & chr(13) & chr(13) & "Destination: " & DestLocation & chr(13) & "Activity: " _
      & Request.Form("Activity") & chr(13) & "Name: " & Request.form("FirstName") _
      & " " & Request.Form("LastName") & chr(13) & "Other Participants: " _
      & Request.Form("OtherNames") & chr(13) & "Address Line 1: " _
      & Request.Form("Address1") & chr(13) & "Address Line 2: " & Request.Form("Address2") _
      & chr(13) & "City: " & Request.Form("City") & chr(13) & "Province/State: " & Request.form("State") _
      & chr(13) & "Country: " & Request.Form("Country") & chr(13) & "Postal/Zip Code: " _
      & Request.Form("PostalCode") & chr(13) & "Daytime Phone: " & Request.Form("Daytime")  & chr(13) _
      & "Evening Phone: " & Request.Form("Evening")  & chr(13) & "Fax: " & Request.Form("Fax")  & chr(13) _
      & "Cell Phone: " & Request.Form("Cell") & chr(13) & chr(13) & "Details: " & Request.Form("Comments") _
       & chr(13) & chr(13) & "For more information on " & DestName & ", please use the following contact information" _
      & chr(13) & chr(13) & DestName & chr(13) & DestAddress _
        & chr(13) & DestState & chr(13) & DestZip & chr(13) _
       & DestCountry & chr(13) & chr(13) & "Toll Free Number: " & DestTollFree _
        & chr(13) & "Telephone: " & DestPhone & chr(13) & "Fax: " & DestFax _
        & chr(13) & "Email: " & DestEmail & chr(13) & "Website: " & DestWebsite
MyMail2.Send
set MyMail2=nothing

response.end
      %>
</body>

</html>
Start Free Trial
 
Keywords: Get the most recent record ID and pas…
 
Loading Advertisement...
 
[+][-]05.02.2004 at 05:03PM PDT, ID: 10973832

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 05:05PM PDT, ID: 10973837

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 05:26PM PDT, ID: 10973882

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 05:30PM PDT, ID: 10973888

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 05:32PM PDT, ID: 10973893

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 06:28PM PDT, ID: 10974079

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: record, asp, recent, most, get
Sign Up Now!
Solution Provided By: rcmb
Participating Experts: 3
Solution Grade: B
 
 
[+][-]05.02.2004 at 07:47PM PDT, ID: 10974290

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 07:50PM PDT, ID: 10974299

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 08:06PM PDT, ID: 10974352

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2004 at 08:13PM PDT, ID: 10974379

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy