navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Passing variable from query

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Passing variable from query
Page: [1]
 
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
Passing variable from query - 5/9/2004 20:10:40   
I am so close to have this working..

The user enters data (Page 1) which is queried (page 2 is the query) to make sure it's not duplicate then directs to another page (3).
On Page 3 user completes data and clicks submit..
Except I'm having trouble passing the initial entries that were queried.

I want to have them pass to page 3 so the user doesn't have to re-enter....
How do I do this?..

I've put a text box at the top and had the value = <%=request.querystring("DateStart")%> -- didn't work
I think I've tried every combination..

Maybe it's not possible to grab that value.. Any help appreciated!
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Passing variable from query - 5/9/2004 20:16:44   
How do you pass the values from page 2 to page 3?

Are you using a form? Hyperlink?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/9/2004 20:21:36   
It's a form...

(in reply to Spooky)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Passing variable from query - 5/9/2004 22:46:21   
So, in the form on page 2, try placing a hidden field :

<input type=hidden name=DateStart value="<%=Request("DateStart")%>">

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/9/2004 23:56:12   
Hi Spooky

It doesn't work... This is the code that checks the database and brings me to the 3rd page..I added the hidden fields..
If I had text boxes to the third page, retype the initial fields, it works great!
I'm trying to save the individual from retyping..


<%
fp_sQry="SELECT * FROM WETASKIWIN1 WHERE (DateStart =  #::DateStart::# AND CampSite LIKE '%::CampSite::%')"
fp_sDefault="DateStart=&CampSite=&DateEnd="
fp_sNoRecords="<tr><td colspan=4 align=left width=""100%""><Script language='Javascript'>window.location='INFOCampWetaskiwin3.asp';</Script></td></tr>"
fp_sDataConn="Database1"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="CAMP"
fp_sMenuValue="CAMP"
fp_iDisplayCols=4
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<tr>
      <td>
<input type="hidden" name="CAMP" VALUE="Camp Wetaskiwin">

<input type=hidden name=DateStart value="<%=Request("DateStart")%>">
      <td>
<input type=hidden name=DateEnd value="<%=Request("DateEnd")%>">
      <td>
<input type=hidden name=CampSite value="<%=Request("CampSite")%>">
    </tr>

 
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</tbody>



</table>

</body>

</html>

(in reply to Spooky)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/10/2004 9:26:18   
I would do this. Delete the middle page. Have the form submit directly to page 3. At the very top of page 3 insert this:

<%
fp_sQry="SELECT COUNT(*) AS MyCount FROM WETASKIWIN1 WHERE (DateStart = #::DateStart::# AND CampSite LIKE '%::CampSite::%')"
fp_sDefault="DateStart=&CampSite=&DateEnd="
fp_sNoRecords=""
fp_sDataConn="Database1"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="CAMP"
fp_sMenuValue="CAMP"
fp_iDisplayCols=4
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<%
If FP_FieldVal(fp_rs,"MyCount")>0 Then
Response.Redirect "INFOCampWetaskiwin3.asp"
End If
%>

<!--#include file="_fpclass/fpdbrgn2.inc"-->

What that does is count the number of records where the campground and date are a match. If the count is zero, the rest of the page loads and the new record is inserted. If there already is a record for that date and campsite, then the redirect occurs. Hope it helps.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/10/2004 13:10:32   
Hi

I've put the code in as you had written... but I'm getting a datatype mismatch error when it loads to the page..
I think I've got something messed up here...
The form that it loads to has all the fp code at the top... (that says don't edit)
Does this query go before that? Can I delete that code?

And if there is a match, or if a record exists I'd like it to redirect to an error page...where does that come in?

At least the values from the first page are being passed!

Thanks
Sarah

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/10/2004 13:35:12   
Can you post the page as it is now?

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/10/2004 13:45:23   
One other thing. I thought this was the error page, INFOCampWetaskiwin3.asp. Is it not? If not, then replace that with the name of the error page in the code above. Meaning, this:

<%
If FP_FieldVal(fp_rs,"MyCount")>0 Then
Response.Redirect "INFOCampWetaskiwin3.asp"
End If
%>


should be:

<%
If FP_FieldVal(fp_rs,"MyCount")>0 Then
Response.Redirect "NameofYourErrorPage.asp"
End If
%>

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to BeTheBall)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/10/2004 14:13:39   
Here's the code from INFOCampWetaskiwin3.asp


<%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.
On Error Resume Next

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
	Err.Clear

	Set fp_conn =  Server.CreateObject("ADODB.Connection")
	FP_DumpError strErrorUrl, "Cannot create connection"

	Set fp_rs = Server.CreateObject("ADODB.Recordset")
	FP_DumpError strErrorUrl, "Cannot create record set"

	fp_conn.Open Application("Database1_ConnectionString")
	FP_DumpError strErrorUrl, "Cannot open database"

	fp_rs.Open "WETASKIWIN1", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
	FP_DumpError strErrorUrl, "Cannot open record set"

	fp_rs.AddNew
	FP_DumpError strErrorUrl, "Cannot add new record set to the database"
	Dim arFormFields0(25)
	Dim arFormDBFields0(25)
	Dim arFormValues0(25)

	arFormFields0(0) = "CAMP"
	arFormDBFields0(0) = "CAMP"
	arFormValues0(0) = Request("CAMP")
	arFormFields0(1) = "SPECIFICS"
	arFormDBFields0(1) = "SPECIFICS"
	arFormValues0(1) = Request("SPECIFICS")
	arFormFields0(2) = "FIRSTNAME"
	arFormDBFields0(2) = "FIRSTNAME"
	arFormValues0(2) = Request("FIRSTNAME")
	arFormFields0(3) = "CHECKOUTTIME"
	arFormDBFields0(3) = "CHECKOUTTIME"
	arFormValues0(3) = Request("CHECKOUTTIME")
	arFormFields0(4) = "REGION"
	arFormDBFields0(4) = "REGION"
	arFormValues0(4) = Request("REGION")
	arFormFields0(5) = "DateEnd"
	arFormDBFields0(5) = "DateEnd"
	arFormValues0(5) = Request("DateEnd")
	arFormFields0(6) = "CampSite"
	arFormDBFields0(6) = "CampSite"
	arFormValues0(6) = Request("CampSite")
	arFormFields0(7) = "CHECKINTIME"
	arFormDBFields0(7) = "CHECKINTIME"
	arFormValues0(7) = Request("CHECKINTIME")
	arFormFields0(8) = "EMAIL"
	arFormDBFields0(8) = "EMAIL"
	arFormValues0(8) = Request("EMAIL")
	arFormFields0(9) = "DateStart"
	arFormDBFields0(9) = "DateStart"
	arFormValues0(9) = Request("DateStart")
	arFormFields0(10) = "PHONE"
	arFormDBFields0(10) = "PHONE"
	arFormValues0(10) = Request("PHONE")
	arFormFields0(11) = "SECTION"
	arFormDBFields0(11) = "SECTION"
	arFormValues0(11) = Request("SECTION")
	arFormFields0(12) = "ADULTS"
	arFormDBFields0(12) = "ADULTS"
	arFormValues0(12) = Request("ADULTS")
	arFormFields0(13) = "LASTNAME"
	arFormDBFields0(13) = "LASTNAME"
	arFormValues0(13) = Request("LASTNAME")
	arFormFields0(14) = "CITY"
	arFormDBFields0(14) = "CITY"
	arFormValues0(14) = Request("CITY")
	arFormFields0(15) = "OTHER"
	arFormDBFields0(15) = "OTHER"
	arFormValues0(15) = Request("OTHER")
	arFormFields0(16) = "SCOUTING"
	arFormDBFields0(16) = "SCOUTING"
	arFormValues0(16) = Request("SCOUTING")
	arFormFields0(17) = "NONSCOUTING"
	arFormDBFields0(17) = "NONSCOUTING"
	arFormValues0(17) = Request("NONSCOUTING")
	arFormFields0(18) = "PROVINCE"
	arFormDBFields0(18) = "PROVINCE"
	arFormValues0(18) = Request("PROVINCE")
	arFormFields0(19) = "AREA"
	arFormDBFields0(19) = "AREA"
	arFormValues0(19) = Request("AREA")
	arFormFields0(20) = "CAMPGROUP"
	arFormDBFields0(20) = "CAMPGROUP"
	arFormValues0(20) = Request("CAMPGROUP")
	arFormFields0(21) = "ADDRESS"
	arFormDBFields0(21) = "ADDRESS"
	arFormValues0(21) = Request("ADDRESS")
	arFormFields0(22) = "YOUTH"
	arFormDBFields0(22) = "YOUTH"
	arFormValues0(22) = Request("YOUTH")
	arFormFields0(23) = "POSTALCODE"
	arFormDBFields0(23) = "POSTALCODE"
	arFormValues0(23) = Request("POSTALCODE")
	arFormFields0(24) = "PASSWORD"
	arFormDBFields0(24) = "PASSWORD"
	arFormValues0(24) = Request("PASSWORD")

	FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

	FP_SaveFieldToDB fp_rs, Now, "stampbooking"

	fp_rs.Update
	FP_DumpError strErrorUrl, "Cannot update the database"

	fp_rs.Close
	fp_conn.Close

	Session("FP_SavedFields")=arFormFields0
	Session("FP_SavedValues")=arFormValues0
	Response.Redirect "confirmation2.asp"

End If
End If

%>

	
<%
fp_sQry="SELECT COUNT(*) AS MyCount FROM WETASKIWIN1 WHERE (DateStart =  #::DateStart::# AND CampSite LIKE '%::CampSite::%')"
fp_sDefault="DateStart=&CampSite=&DateEnd="
fp_sNoRecords=""
fp_sDataConn="Database1"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="CAMP"
fp_sMenuValue="CAMP"
fp_iDisplayCols=4
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<%
If FP_FieldVal(fp_rs,"MyCount")>0 Then
Response.Redirect "INFOCampWetaskiwin3.asp"
End if
%>
<!--#include file="_fpclass/fpdbrgn2.inc"-->

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>SPECIFICS</title>
<meta name="Microsoft Theme" content="blends 111, default">
</head>

<body>
<form method="POST" name="FrontPage_Form1" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)">
  <!--webbot bot="SaveDatabase" suggestedext="asp" u-asp-include-url="_fpclass/fpdbform.inc" s-dataconnection="Database1" s-recordsource="WETASKIWIN1" u-confirmation-url="confirmation2.asp" s-builtin-fields="Timestamp" s-builtin-dbfields="stampbooking" s-form-fields="CAMP SPECIFICS FIRSTNAME CHECKOUTTIME REGION DateEnd CampSite CHECKINTIME EMAIL DateStart PHONE SECTION ADULTS LASTNAME CITY OTHER SCOUTING NONSCOUTING PROVINCE AREA CAMPGROUP ADDRESS YOUTH POSTALCODE PASSWORD" s-form-dbfields="CAMP SPECIFICS FIRSTNAME CHECKOUTTIME REGION DateEnd CampSite CHECKINTIME EMAIL DateStart PHONE SECTION ADULTS LASTNAME CITY OTHER SCOUTING NONSCOUTING PROVINCE AREA CAMPGROUP ADDRESS YOUTH POSTALCODE PASSWORD" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan i-checksum="40548" --><p>
  Camp: <font size="1">
  <!--webbot bot="Validation" s-display-name="FIRSTNAME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="CAMP" size="22" value="<%=request("CAMP")%>" maxlength="255"></font></p>
  <p> </p>
  <p><font size="1">Dates you have entered:<br>
  Start Date
  <!--webbot bot="Validation" s-display-name="FIRSTNAME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="DateStart" size="22" value="<%=request("DateStart")%>" maxlength="255"></font></p>
<p>End Date: <font size="1">
<!--webbot bot="Validation" s-display-name="FIRSTNAME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="DateEnd" size="22" value="<%=request("DateEnd")%>" maxlength="255"><br>
Camp Site(s):
<!--webbot bot="Validation" s-display-name="FIRSTNAME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="CampSite" size="22" value="<%=request("CampSite")%>" maxlength="255"></font></p>
<p><b><font size="1">SPECIFICS</font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="SPECIFICS" s-data-type="String" b-value-required="False" i-maximum-length="0" --><textarea rows="2" name="SPECIFICS" cols="48"></textarea><br>
</font>
</p>
  <hr>
<p><font size="1">Contact information <br>
</font><b><font size="1">FIRST NAME </font></b><font size="1"> <!--webbot bot="Validation" s-display-name="FIRSTNAME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="FIRSTNAME" size="22" value="" maxlength="255">  
</font><b><font size="1">LAST NAME  </font></b><font size="1"> <!--webbot bot="Validation" s-display-name="LASTNAME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="LASTNAME" size="26" value="" maxlength="255"><br>
</font><b><font size="1">ADDRESS</font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="ADDRESS" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="ADDRESS" size="64" value="" maxlength="255"><br>
</font><b><font size="1">CITY</font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="CITY" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="CITY" size="12" value="" maxlength="255"> 
</font><b><font size="1">PROVINCE</font></b><font size="1"> <!--webbot bot="Validation" s-display-name="PROVINCE" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="PROVINCE" size="13" value="ONTARIO" maxlength="255"></font><b><font size="1">   POSTAL  CODE</font></b><font size="1"> <!--webbot bot="Validation" s-display-name="POSTALCODE" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="POSTALCODE" size="7" value="" maxlength="255"> 
</font><b><font size="1"><br>
PHONE</font></b><font size="1">
<!--webbot bot="Validation" s-display-name="PHONE" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="PHONE" size="22" value="" maxlength="255">  
(519-777-7777)<br>
<br>
</font><b><font size="1"><br>
REGION</font></b><font size="1"><br>
<select size="1" name="REGION">
<option>TRI-SHORES</option>
<option>BATTLEFIELDS</option>
<option>CENTRAL ESCARPMENT</option>
<option>OTHER</option>
</select>   </font><b><font size="1">AREA  </font></b>
<font size="1"> <!--webbot bot="Validation" s-display-name="AREA" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="AREA" size="26" value="" maxlength="255"><br>
<br>
</font><b><font size="1">GROUP</font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="CAMPGROUP" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="CAMPGROUP" size="31" value="" maxlength="255"> 
</font><b><font size="1">SECTION  </font></b><font size="1"> <select size="1" name="SECTION">
<option>.....</option>
<option>BEAVERS</option>
<option>CUBS</option>
<option>SCOUTS</option>
<option>VENTURERS</option>
<option>ROVERS</option>
<option>TRAINING</option>
<option>OTHER</option>
</select><br>
</font><b><font size="1">YOUTH </font></b><font size="1"> <!--webbot bot="Validation" s-display-name="YOUTH" s-data-type="Number" s-number-separators="x." b-value-required="False" i-maximum-length="16" --><input name="YOUTH" size="8" value="0" maxlength="16"></font><b><font size="1">ADULTS</font></b><font size="1"> 
<!--webbot bot="Validation" s-display-name="ADULTS" s-data-type="Number" s-number-separators="x." b-value-required="False" i-maximum-length="16" --><input name="ADULTS" size="7" value="0" maxlength="16"><br>
</font>
<b><font size="1">OTHER</font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="OTHER" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="OTHER" size="64" value="" maxlength="255"><br>
<br>
</font>
<b><font size="1">CHECKINTIME  </font></b><font size="1"> <!--webbot bot="Validation" s-display-name="CHECKINTIME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="CHECKINTIME" size="17" value="" maxlength="255"> 
</font><b><font size="1">CHECKOUTTIME</font></b><font size="1"> 
<!--webbot bot="Validation" s-display-name="CHECKOUTTIME" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="CHECKOUTTIME" size="18" value="" maxlength="255"><br>
</font>
<b><font size="1">SCOUTING GROUP? </font></b><font size="1"> <select size="1" name="SCOUTING">
<option>YES</option>
<option>NO</option>
</select>  </font><b><font size="1">NON-SCOUTING  </font></b>
<font size="1"> <select size="1" name="NONSCOUTING">
<option>NO</option>
<option>YES</option>
</select><br>
<br>
</font>
<b><font size="1">EMAIL</font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="EMAIL" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="EMAIL" size="64" value="" maxlength="255"><br>
The email you provide is where the confirmation forms will be sent... if you 
cannot provide an email please type "NA"</font></p>
<p><b><font size="1">PASSWORD</font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="PASSWORD" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input name="PASSWORD" size="33" value="" maxlength="255"></font></p>


  <p> </p>
  <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>


</form>

</body>

</html>

(in reply to BeTheBall)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/10/2004 16:05:45   
Should the code be posted to the error page then?

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/10/2004 16:12:31   
The code I provided should go on the same page as the code that performs the INSERT. As for the page you posted here, not sure where that fits into the equation. You should have a page with your form. That form should submit to the page whereon sits the code that performs the INSERT or redirects if the value already exists in the db. Finally, you should have a page where duplicate entries would be redirected. That's it.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/10/2004 22:51:06   
Hi Duane
Thanks for helping me..
Part of my problem is that I've got on e extra page in there.
I'd like to do the query on dates and sites (page1)...(page 2 is the query) if all ok redirects to new form where fill out name address etc.(page3) which then submits to database... get confirmation form etc.

It's passing the variables from page 1 ---do query---then grab them in the page 3.
I'm thinking I could submit them to the database... do query... then use DRW to bring them back up again. Make sense? I read something like that in another post.

Any ideas?...

If interested the link is http://www.trishores-scouts.on.ca/campbookings1/INFOCampWetaskiwin2.asp

Thanks

(in reply to BeTheBall)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/11/2004 11:15:03   
Hi again...
I've gone back to doing as you said with the 3 pages.. just want to get that to work..
page 1 form input
goes to page 2 insert statement

The insert page is giving me a syntax error
I've put the query code at the top .

Help with Insert..
Also.. Does fp automatically send the time stamp? or do I have to include that as a hidden field.?
Thanks


<% 
fp_sQry="SELECT COUNT(*) AS MyCount FROM WETASKIWIN1 WHERE (DateStart = #::DateStart::# AND CampSite LIKE '%::CampSite::%')" 
fp_sDefault="DateStart=01/09/2004&CampSite=" 
fp_sNoRecords="" 
fp_sDataConn="Database1" 
fp_iMaxRecords=256 
fp_iCommandType=1 
fp_iPageSize=0 
fp_fTableFormat=True 
fp_fMenuFormat=False 
fp_sMenuChoice="CAMP" 
fp_sMenuValue="CAMP" 
fp_iDisplayCols=4 
fp_fCustomQuery=False 
BOTID=0 
fp_iRegion=BOTID 
%> 
<!--#include file="_fpclass/fpdbrgn1.inc"--> 
<% 
If FP_FieldVal(fp_rs,"MyCount")>0 Then 
Response.Redirect "subheaderfiles/errorpage.asp" 
End If 
%> 

<!--#include file="_fpclass/fpdbrgn2.inc"--> 


<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Insert page</title>
</head>

<body>

<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="INSERT INTO WETASKIWIN1 (CAMP, DateStart, DateEnd, SPECIFICS, ADDRESS, CITY, PROVINCE, POSTALCODE, REGION, CAMPGROUP, [SECTION], YOUTH, ADULTS, EMAIL, OTHER, AREA, FIRSTNAME, LASTNAME, PHONE, [PASSWORD], CHECKINTIME, CHECKOUTTIME, SCOUTING, NONSCOUTING, CampSite) VALUES ( '::CAMP::', #::DateStart::#, #::DateEnd::#, '::SPECIFICS::', '::ADDRESS::', '::CITY::', '::PROVINCE::', '::POSTALCODE::', '::REGION::', '::CAMPGROUP::', '::SECTION::', ::YOUTH::, ::ADULTS::, '::EMAIL::', '::OTHER::', '::AREA::', '::FIRSTNAME::', '::LASTNAME::', '::PHONE::', '::PASSWORD::', '::CHECKINTIME::', '::CHECKOUTTIME::', '::SCOUTING::', '::NONSCOUTING::', '::CampSite::',)"
fp_sDefault="CAMP=Camp WetaskiwinDateStart=01/09/2004DateEnd=01/09/2004SPECIFICS=&ADDRESS=&CITY=&PROVINCE=&POSTALCODE=®ION=&CAMPGROUP=&SECTION=&YOUTH=&ADULTS=&EMAIL=&OTHER=&AREA=&FIRSTNAME=&LASTNAME=&PHONE=&PASSWORD=&CHECKINTIME=&CHECKOUTTIME=&SCOUTING=&NONSCOUTING=&CampSite="
fp_sNoRecords="" 
fp_sDataConn="Database1"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<form METHOD="POST">
<!--#include file="_fpclass/fpdbrgn2.inc"--> 

</form>

</body></html>

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/11/2004 18:50:26   
A couple more questions on what you need to do. For example, it appears you are relying on the StartDate to determine if the site is already booked. Are the campsites normally booked for a week at a time? For example, suppose someone books a site from Monday-Saturday. Is it conceivable that someone else could try to book it for Tuesday-Saturday of the same week? Since the start date is different, the code would not see a problem. Just wondering if that is something you need to code for or not.

Essentially what you need is a two part form. The first part chooses the campsite and dates and part 2 does everything else, right? The issue is getting the data from part one to go to part two since, technically, part 2 takes care of getting the data to the database.

Frontpage offers two methods of inserting data to a db. One, and the most commonly used, is to have a form submit directly to a database, which is what it appears you were doing originally. The other is to have the form submit to another page and from there to the database. If doing the latter, then you need the type of code I provided earlier, i.e, the INSERT INTO statement.

So . . . you already have a form wherein the user enters the dates and the desired campsites. However, when viewing the link you provided, I received error messages both when the page loaded and when submitting the form. Those need to be resolved. Once resolved, I would verify the redirect process works properly. Meaning, purposely enter a date and campsite that already exist in the db to make sure the user is redirected as necessary. Then, add the INSERT code to the page and get that running.

You asked about Timestamp. That is a field FP adds when it creates a database for you. Do you need it? If not, simply delete it from the database. If you do need it, you would need to include it in the INSERT statement. I would, at the very least rename the field in the db as Timestamp is a reserved word and will cause you trouble down the road.

You still probably have lost of questions, so let just see if we can get you going one step at a time, step one being getting the first part of the form (the date and campsite portion) working properly.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/11/2004 19:16:42   
Hi Duane
First, thanks so much! You are the best helping me with this.

I've got the Page 1 sending the query to Page 2, with the error page working.

And I've also got Page 3 sending to an Page 4 which is the insert page.
It works and inserts the data from page 3, but not page 1..

With me?
There's a bridge here between Page 2 and Page 3 that I'm not sure how to do..

Changed the url for the page ...
http://www.trishores-scouts.on.ca/campbookings1/Wetaskiwin/INFOCampWetaskiwin2.asp

Sarah

< Message edited by rikki -- 5/11/2004 20:01:02 >

(in reply to BeTheBall)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/11/2004 19:46:14   
I changed to code to keep those inbetween dates from slipping in!


Thanks

< Message edited by rikki -- 5/11/2004 19:58:26 >

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/11/2004 20:50:12   
OK, I visited your URL and saw no errors. The form submitted and took me to a blank page titled query4.asp. What is the code for query4.asp? What I think needs to happen is that page should redirect either to the rest of the form or the error page. If we redirect to the rest of the form, we will have to put all the form fields from form one into the URL of the redirect so they will be available to the second form. Post the code that you have on that page so far and let's see if we can get it to do as I suggest.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/11/2004 21:24:35   
This is the code query4.asp

<!--#include file="../_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT COUNT(*) AS MyCount FROM WETASKIWIN1 WHERE (DateStart BETWEEN #::DateStart::# AND #::DateEnd::#) AND (CampSite LIKE '%::CampSite::%')"
fp_sDefault="DateStart=&CampSite="
fp_sNoRecords="<tr><td colspan=3 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Database1"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=3
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%><!--#include file="../_fpclass/fpdbrgn1.inc"-->

<%
If FP_FieldVal(fp_rs,"MyCount")>0 Then
Response.Redirect "../subheaderfiles/errorpage.htm"
End if
%><!--#include file="../_fpclass/fpdbrgn2.inc"-->

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/12/2004 9:19:09   
OK. Now, change this:

<%
If FP_FieldVal(fp_rs,"MyCount")>0 Then
Response.Redirect "../subheaderfiles/errorpage.htm"
End if
%>

to

<%
If FP_FieldVal(fp_rs,"MyCount")>0 Then
Response.Redirect "../subheaderfiles/errorpage.htm"
Else
Response.Redirect "NameofPagethathasrestofyourform.asp"
End if
%>

Let me know if that works properly and then we can add parameters to the above link so that the values from the the first form are carried to the second.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/12/2004 9:46:22   
Hi
It works.. and I tried it with an existing record.. it took me to the errorpage like it's suppose to...And to the next page if not duplicate

< Message edited by rikki -- 5/12/2004 10:08:52 >

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/12/2004 18:43:55   
Looks like you also figured out how to populate the date and campsite fields on INFOCampWetaskiwin3.asp. Do you need further assitance or have you got it where you want?

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
rikki

 

Posts: 382
Joined: 4/4/2004
Status: offline

 
RE: Passing variable from query - 5/12/2004 18:59:28   
Perseverance and trial and error pay off! Thanks so much for your help.
All is working...!!!

< Message edited by rikki -- 5/12/2004 21:24:21 >

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Passing variable from query - 5/13/2004 13:44:23   
Congratulations. You are learning fast!

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rikki)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Passing variable from query
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts