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

 

RE: Querying Comma Separated Values

 
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 >> RE: Querying Comma Separated Values
Page: <<   < prev  1 [2] 3   next >   >>
 
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/29/2004 10:22:49   
The problem with the DRW is it won't allow us to do some of the next steps in the process. Using the code I gave you, write out the SQL. Just below the <body> tag insert:

<%=mySQL%>

When you test, are you first filling out the form where you enter the dates and then having the form submit to this page? Seems like maybe the dates are not being passed. You can also enter this code in the body to make sure the dates are being passed:

<%=Request.Form("DateStart")%>
<%=Request.Form("DateEnd")%>

< Message edited by betheball -- 5/29/2004 12:38:47 >


_____________________________

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: 6354
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Querying Comma Separated Values - 5/29/2004 15:42:11   
My fault. I combined pure asp and frontpage in the SQL statement. Let's revise the code a bit. Try this:

<%
Dim conntemp, myDSN, myRS, mySQL, arrCampSite, varDateStart, varDateEnd
varDateStart = Request.Form("DateStart")
varDateEnd = Request.Form("DateEnd")
Set conntemp=Server.CreateObject("ADODB.Connection")
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/trishores-scouts/fpdb/NameofyourDB.mdb")
conntemp.open myDSN
mySQL = "SELECT CampSite FROM WETASKIWIN1 WHERE ([DateStart] Between #"&varDateStart&"# And #"&varDateEnd&"#) OR ([DateEnd] Between #"&varDateStart&"# And #"&varEndStart&"#) "
Set myRS = Server.CreateObject("ADODB.Recordset")
myRS.Open mySQL, conntemp, 0, 1
If myRS.eof OR myRS.bof then
RecordFound=0
Else
arrCampSite = myRS.GetString(,,,"<br>")
RecordFound=-1
End if
myRS.Close
Set myRS = nothing
conntemp.Close
Set conntemp = nothing
%>

Then, after the <body> tag, insert this:

The following campsite(s) is/are reserved for the day(s) you selected:<br><br>
<%
If RecordFound then
Response.Write arrCampSite
else
Response.Write("All sites are available")
End if
%>

See if that works better.

_____________________________

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: Querying Comma Separated Values - 5/29/2004 22:06:30   
Hi Duane
When I enter the dates and click submit... I get an "internal server error"

I'm going to play with it a bit more...

< Message edited by rikki -- 5/29/2004 22:09:06 >

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/30/2004 11:50:18   
Do you have the "Show Friendly HTTP Messages" option turned off in Internet Explorer? It needs to be in order to get a more descriptive error message.

_____________________________

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: Querying Comma Separated Values - 5/30/2004 13:54:13   
I figured out the problem below... I now get a returned page as follows:
The following campsite(s) is/are reserved for the day(s) you selected:

When I enter a date that I know is not in the database I get this.
The following campsite(s) is/are reserved for the day(s) you selected:

All sites are available

Here's the error page now ( I turned off the friendly errors...
There seems to be something wrong with the DateStart field in the last part of the query...

Microsoft JET Database Engine error '80040e07'

Syntax error in date in query expression '([DateStart] Between #june 12/04# And #june 12/04#) OR ([DateEnd] Between #june 12/04# And ##)'.

/campbookings1/1WETASKIWIN/3DateQuery.asp, line 10

Line 10 refers to this code
myRS.Open mySQL, conntemp, 0, 1 


< Message edited by rikki -- 5/30/2004 13:57:22 >

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/30/2004 14:13:40   
Ahh, c'mon Sarah, you gotta be able to catch some of my stupidity! :) Look at the SQL I gave you:

mySQL = "SELECT CampSite FROM WETASKIWIN1 WHERE ([DateStart] Between #"&varDateStart&"# And #"&varDateEnd&"#) OR ([DateEnd] Between #"&varDateStart&"# And #"&varEndStart&"#) "

This:

#"&varEndStart&"#

Of course should be:

#"&varDateEnd&"#

_____________________________

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: Querying Comma Separated Values - 5/30/2004 14:38:33   
I'm so impressed with myself... I did figure it out... See my note above.
I'm sure that was to see if I was paying attention!:)

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/30/2004 14:46:06   
So this SQL:

mySQL = "SELECT CampSite FROM WETASKIWIN1 WHERE ([DateStart] Between #"&varDateStart&"# And #"&varDateEnd&"#) OR ([DateEnd] Between #"&varDateStart&"# And #"&varDateEnd&"#) "

Is still generating this error?

Microsoft JET Database Engine error '80040e07'

Syntax error in date in query expression '([DateStart] Between #june 12/04# And #june 12/04#) OR ([DateEnd] Between #june 12/04# And ##)'.

/campbookings1/1WETASKIWIN/3DateQuery.asp, line 10

If so, please post your current code.

_____________________________

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: Querying Comma Separated Values - 5/30/2004 16:56:53   
No Error now...

I get the following results...
For a date that is already in the database...
The following campsite(s) is/are reserved for the day(s) you selected:

For a date that is not in the database....
The following campsite(s) is/are reserved for the day(s) you selected:

All sites are available

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/30/2004 18:22:24   
Yet another oversite on my part. (Keep in mind that I am just weening myself off the DRW as well). Change the code in the body to this:

The following campsite(s) is/are reserved for the day(s) you selected:<br><br>
<%
If RecordFound = 0 then
Response.Write arrCampSite
else
Response.Write("All sites are available")
End if
%>

< Message edited by betheball -- 5/30/2004 16:23:43 >


_____________________________

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: Querying Comma Separated Values - 5/31/2004 10:49:39   
Hi Duane
I've posted the code below...
When I submit a date in the database I get the following:
The following campsite(s) is/are reserved for the day(s) you selected:

All sites are available

When I submit a date not in the database I get the following:
The following campsite(s) is/are reserved for the day(s) you selected:



<% 
Dim conntemp, myDSN, myRS, mySQL, arrCampSite, varDateStart, varDateEnd 
varDateStart = Request.Form("DateStart") 
varDateEnd = Request.Form("DateEnd") 
Set conntemp=Server.CreateObject("ADODB.Connection") 
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../fpdb/index.mdb") 
conntemp.open myDSN 
mySQL = "SELECT CampSite FROM WETASKIWIN1 WHERE ([DateStart] Between #"&varDateStart&"# And #"&varDateEnd&"#) OR ([DateEnd] Between #"&varDateStart&"# And #"&varDateEnd&"#) " 
Set myRS = Server.CreateObject("ADODB.Recordset") 
myRS.Open mySQL, conntemp, 0, 1 
If myRS.eof OR myRS.bof then 
RecordFound=0 
Else 
arrCampSite = myRS.GetString(,,,"<br>") 
RecordFound=-1 
End if 
myRS.Close 
Set myRS = nothing 
conntemp.Close 
Set conntemp = nothing 
%> 
<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>New Page 3</title>
</head>

<body>The following campsite(s) is/are reserved for the day(s) you selected:<br><br> 
<% 
If RecordFound = 0 then 
Response.Write arrCampSite 
else 
Response.Write("All sites are available") 
End if 
%>  </body>

</html>

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/31/2004 11:21:13   
Change this:

If RecordFound = 0 then

to

If RecordFound <> 0 then

_____________________________

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: Querying Comma Separated Values - 5/31/2004 11:27:49   
An existing date returns
The following are reserved for that date:


A new date returns:
The following are reserved for that date:

All sites are available

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/31/2004 11:32:39   
Just to make sure the variable is getting populated, try replacing:

<%
If RecordFound = 0 then
Response.Write arrCampSite
else
Response.Write("All sites are available")
End if
%>

With simply:

<%=arrCampSite%>

_____________________________

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: Querying Comma Separated Values - 5/31/2004 12:29:48   
Yep, the value is being passed

This is what I get for date in the database..

The following are reserved for that date:

Lodge

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/31/2004 12:37:07   
Great! So now put this back. I changed it just a bit.

<%
If RecordFound = 0 then
Response.Write ("All sites are available")
else
Response.Write(arrCampSite)
End if
%>

If that works, then add the form to the page. Name the checkboxes for the campsites sequentially, i.e., CampSite1, CampSite2, CampSite3, etc. Then, you can modify the code for each checkbox so that it becomes disabled if its corresponding value is in the list of reserved sites. For example:

<input type="checkbox" name="CheckBox1" value="Lodge" <%If Instr(arrCampSite, "Lodge") Then Response.Write(" disabled")End IF%>>

We're getting there, I promise.

_____________________________

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: Querying Comma Separated Values - 5/31/2004 12:52:03   
You are a genius! Worked great!

Should I go ahead and add all the text boxes... name etc.?
The checkboxes are blank where appropriate!

Sarah

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/31/2004 12:59:22   
Yes, add the whole form. Don't forget hidden fields to capture the dates from the first form. In fact, if you want you can use text fields and then, like the checkboxes, include " disabled" so that the user sees the dates but cannot change them. For example:

<input type="text" name="T1" size="20" value="<%=varDateStart%>" disabled>
<input type="text" name="T1" size="20" value="<%=varDateEnd%>" disabled>

However, you still will need the hidden fields because a disabled field will not insert.

(I just learned about the "disabled" attribute. Pretty cool, isn't it?!)

< Message edited by betheball -- 5/31/2004 11:00:53 >


_____________________________

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: Querying Comma Separated Values - 5/31/2004 15:04:07   
Hi Duane
I've got the date field showing...
The rest of the form is loaded and working

My question is:
I tried sending the form using the frontpage "Send to DAtabase"
didn't properly send the new campsite field.

I wrote an insert query...
But it doesn't pass the field either...
I'm sure it's because I am using frontpage and not just straight sql

The dates are hidden fields and are passing.

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/31/2004 17:53:21   
Create a new page, say, Insert_Reservation.asp. Place the code below in the body of the new page. Then right-click your form, choose, form properties, check the "Send to other" option, click the Options button and have the form submit to Insert_Reservation.asp

<% DIM conntemp, mySQL, myDSN 

myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../fpdb/index.mdb")
'myDSN would be specific to your environment

set conntemp=server.createobject("adodb.connection") 
conntemp.open myDSN 

FOR i = 1 to 11 

	IF Request("CampSite" & i) <> "" THEN 

	mySQL = "INSERT INTO WETASKIWIN1"
	mySQL = & "(BOOKINGNUMBER, 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, stampbooking)" 
	mySQL = & "VALUES(" & Request.Form("BOOKINGNUMBER") & ""
	mySQL = & "'" & Replace(Request.Form("CAMP"),"'","''") & "'"
	mySQL = & "#" & Request.Form("DateStart") & "#"
	mySQL = & "#" & Request.Form("DateEnd") & "#"
	mySQL = & "'" & Replace(Request.Form("SPECIFICS"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("ADDRESS"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("CITY"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("PROVINCE"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("POSTALCODE"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("REGION"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("CAMPGROUP"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("SECTION"),"'","''") & "'"
	mySQL = & "" & Request.Form("YOUTH") & ""
	mySQL = & "" & Request.Form("ADULTS") & ""
	mySQL = & "'" & Replace(Request.Form("EMAIL"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("OTHER"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("AREA"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("FIRSTNAME"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("LASTSTNAME"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("PHONE"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("CHECKINTIME"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("CHECKOUTTIME"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("SCOUTING"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("NONSCOUTING"),"'","''") & "'"
	mySQL = & "'" & Replace(Request.Form("CampSite" & i),"'","''") & "'"
	mySQL = & "#" & Request.Form("stampbooking") & "#)"
	
conntemp.execute(mySQL) 

END IF 

NEXT 

conntemp.close 
set conntemp=nothing 
Response.write "Resevation added."
%>


Now, I will be shocked if this works on the first try as I have modified some existing code that I use in another application and likely missed something. The idea is the code loops through and adds a new record for each campsite checked.

_____________________________

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: Querying Comma Separated Values - 5/31/2004 19:57:45   
Duane
It doesn't like the & after the mySQL=..
You can't see the arrow but it's pointing to that first &

Error:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/campbookings1/1WETASKIWIN/4InsertQuery.asp, line 15

mySQL = & "VALUES(" & Request.Form("BOOKINGNUMBER") & ""


Also, I know it's jumping ahead but what about a custom confirmation page.?

< Message edited by rikki -- 5/31/2004 19:59:20 >

(in reply to rikki)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/31/2004 21:38:43   
I can see two glaring errors on my part. I don't normally build my SQL strings like this because I inevitably make mistakes but we'll keep trying. At the beginning of each line of the SQL, other than the first, it should be mySQL = mySQL & etc. Also, I forgot the commas that go between each field being inserted. Here is attempt number two:

<% DIM conntemp, mySQL, myDSN 

myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../fpdb/index.mdb")
'myDSN would be specific to your environment

set conntemp=server.createobject("adodb.connection") 
conntemp.open myDSN 


FOR i = 1 to 11 

	IF Request("Employee" & i) <> "Select One" THEN 

	mySQL = "INSERT INTO WETASKIWIN1"
	mySQL = mySQL & "(BOOKINGNUMBER, 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, stampbooking)" 
	mySQL = mySQL & "VALUES(" & Request.Form("BOOKINGNUMBER") & ","
	mySQL = mySQL & "'" & Replace(Request.Form("CAMP"),"'","''") & "',"
	mySQL = mySQL & "#" & Request.Form("DateStart") & "#,"
	mySQL = mySQL & "#" & Request.Form("DateEnd") & "#,"
	mySQL = mySQL & "'" & Replace(Request.Form("SPECIFICS"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("ADDRESS"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CITY"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("PROVINCE"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("POSTALCODE"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("REGION"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CAMPGROUP"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("SECTION"),"'","''") & "',"
	mySQL = mySQL & "" & Request.Form("YOUTH") & ","
	mySQL = mySQL & "" & Request.Form("ADULTS") & ","
	mySQL = mySQL & "'" & Replace(Request.Form("EMAIL"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("OTHER"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("AREA"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("FIRSTNAME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("LASTSTNAME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("PHONE"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CHECKINTIME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CHECKOUTTIME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("SCOUTING"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("NONSCOUTING"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CampSite" & i),"'","''") & "',"
	mySQL = mySQL & "#" & Request.Form("stampbooking") & "#)"
	
conntemp.execute(mySQL) 

END IF 

NEXT 

conntemp.close 
set conntemp=nothing 
Response.write "Resevation added."
%>


_____________________________

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: Querying Comma Separated Values - 5/31/2004 21:49:29   
I am getting a syntax error...



Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/campbookings1/1WETASKIWIN/4InsertQuery.asp, line 43

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 5/31/2004 22:02:38   
Not sure this is the only problem, but I missed a line:

After this:

mySQL = mySQL & "'" & Replace(Request.Form("PHONE"),"'","''") & "',"

Enter:

mySQL = mySQL & "'" & Replace(Request.Form("PASSWORD"),"'","''") & "',"

If that fails, try adding:

Response.write mySQL
Response.End

Right after:

NEXT

That may clue us in to any more problems.

_____________________________

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: Querying Comma Separated Values - 5/31/2004 22:12:09   
Still get a syntax error
even with the response.write...

I made one change
FOR i = 1 to 26

< Message edited by rikki -- 5/31/2004 22:39:20 >

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 6/1/2004 8:24:17   
quote:

I made one change
FOR i = 1 to 26


That's part of the problem. The 26 needs to be changed to the number of campsite checkboxes. Hopefully you named them sequentially, CampSite1 - Campsite(Some Number) However many campsite checkboxes you have should be the second number in this line:

FOR i = 1 to X

I put 11 in my code thinking that was how many campsite there were. If there are less, change to the lesser number.

_____________________________

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: Querying Comma Separated Values - 6/1/2004 21:45:31   
Just to make sure we are both on the same page here's the insert code as I have it... I get this error:
Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/campbookings1/1WETASKIWIN/4InsertQuery.asp, line 44

<% DIM conntemp, mySQL, myDSN 

myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../fpdb/index.mdb")
'myDSN would be specific to your environment

set conntemp=server.createobject("adodb.connection") 
conntemp.open myDSN 


FOR i = 1 to 26

	IF Request("CampSite" & i) <> "" THEN 

	mySQL = "INSERT INTO WETASKIWIN1"
	mySQL = mySQL & "(BOOKINGNUMBER, 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, stampbooking)" 
	mySQL = mySQL & "VALUES(" & Request.Form("BOOKINGNUMBER") & ","
	mySQL = mySQL & "'" & Replace(Request.Form("CAMP"),"'","''") & "',"
	mySQL = mySQL & "#" & Request.Form("DateStart") & "#,"
	mySQL = mySQL & "#" & Request.Form("DateEnd") & "#,"
	mySQL = mySQL & "'" & Replace(Request.Form("SPECIFICS"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("ADDRESS"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CITY"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("PROVINCE"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("POSTALCODE"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("REGION"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CAMPGROUP"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("SECTION"),"'","''") & "',"
	mySQL = mySQL & "" & Request.Form("YOUTH") & ","
	mySQL = mySQL & "" & Request.Form("ADULTS") & ","
	mySQL = mySQL & "'" & Replace(Request.Form("EMAIL"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("OTHER"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("AREA"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("FIRSTNAME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("LASTSTNAME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("PHONE"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("PASSWORD"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CHECKINTIME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CHECKOUTTIME"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("SCOUTING"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("NONSCOUTING"),"'","''") & "',"
	mySQL = mySQL & "'" & Replace(Request.Form("CampSite" & i),"'","''") & "',"
	mySQL = mySQL & "#" & Request.Form("stampbooking") & "#,"
	
conntemp.execute (mySQL) 

END IF 

NEXT 

conntemp.close 
set conntemp=nothing 
Response.write "Reservation added."
%>

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: Querying Comma Separated Values - 6/1/2004 22:08:44   
You'd better post your form as well. Just post everything between the <form> and </form> tags.

_____________________________

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: 6354
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Querying Comma Separated Values - 6/1/2004 22:24:14   
There should be no comma in the last line of the SQL and there should be a closing parenthesis.

This:

mySQL = mySQL & "#" & Request.Form("stampbooking") & "#,"

Should be:

mySQL = mySQL & "#" & Request.Form("stampbooking") & "#)"

_____________________________

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: Querying Comma Separated Values - 6/1/2004 22:57:57   
Here's the form page too...




 <form method="POST" name="FrontPage_Form1" action="4InsertQuery.asp" onsubmit="return FrontPage_Form1_Validator(this)">
   <div align="left"> 
                  <font size="1">
                  <input type="text" name="DateStart" size="20" value="<%=varDateStart%>" disabled> 
                  (to change these dates click the back button on your browser)</div>
<input type="text" name="DateEnd" size="20" value="<%=varDateEnd%>" disabled> <br>
   <br>
   Please select the sites you are booking:<br>
   </font><b>Buildings</b><br>
                  <font size="1">

	<input type="checkbox" name="CampSite1" value="Lodge" <%If Instr(arrCampSite,"Lodge") Then Response.Write("disabled")End IF%>>Lodge<br>
    <input type="checkbox" name="CampSite2" value="Bunkhouse" <%If Instr(arrCampSite,"Bunkhouse") Then Response.Write("disabled")End IF%>> Bunkhouse<br>
    <input type="checkbox" name="CampSite3" value="Potlatch" <%If Instr(arrCampSite,"Potlatch") Then Response.Write("disabled")End IF%>> Potlatch<br>
          <input type="checkbox" name="CampSite4" value="BBQ" <%If Instr(arrCampSite,"BBQ") Then Response.Write("disabled")End IF%>>
          BBQ (2 GRILL PROPANE BBQ)<br>
    <input type="checkbox" name="CampSite5" value="Cabins" <%If Instr(arrCampSite,"Cabins") Then Response.Write("disabled")End IF%>> CABINS<br>
    <input type="checkbox" name="CampSite6" value="Pool" <%If Instr(arrCampSite,"Pool") Then Response.Write("disabled")End IF%>>
          POOL (only available July 31-Aug31)</font><p><b>Tenting</b><font size="1"><br>
    <input type="checkbox" name="CampSite7" value="Site1" <%If Instr(arrCampSite,"Site1") Then Response.Write("disabled")End IF%>>Camp Site 1<br>
    <input type="checkbox" name="CampSite8" value="Site2" <%If Instr(arrCampSite,"Site2") Then Response.Write("disabled")End IF%>>Camp Site 2
   <br>
    <input type="checkbox" name="CampSite9" value="Site3" <%If Instr(arrCampSite,"Site3") Then Response.Write("disabled")End IF%>>Camp Site 3
   <br>
    <input type="checkbox" name="CampSite10" value="Site4" <%If Instr(arrCampSite,"Site4") Then Response.Write("disabled")End IF%>>Camp Site 4
   <br>
    <input type="checkbox" name="CampSite11" value="Site5" <%If Instr(arrCampSite,"Site5") Then Response.Write("disabled")End IF%>>Camp 
   Site 5 <br>
    <input type="checkbox" name="CampSite12" value="Site6" <%If Instr(arrCampSite,"Site6") Then Response.Write("disabled")End IF%>>Camp 
   Site 6 <br>
    <input type="checkbox" name="CampSite13" value="Site7" <%If Instr(arrCampSite,"Site7") Then Response.Write("disabled")End IF%>>Camp 
   Site 7 <br>
    <input type="checkbox" name="CampSite14" value="Site8" <%If Instr(arrCampSite,"Site8") Then Response.Write("disabled")End IF%>>Camp 
   Site 8 <br>
    <input type="checkbox" name="CampSite15" value="Site9" <%If Instr(arrCampSite,"Site9") Then Response.Write("disabled")End IF%>>Camp 
   Site 9<br>
    <input type="checkbox" name="CampSite16" value="Site10" <%If Instr(arrCampSite,"Site10") Then Response.Write("disabled")End IF%>>Camp 
   Site 10<br>
    <input type="checkbox" name="CampSite17" value="Site11" <%If Instr(arrCampSite,"Site11") Then Response.Write("disabled")End IF%>>Camp 
   Site 11 <br>
    <input type="checkbox" name="CampSite18" value="Site12" <%If Instr(arrCampSite,"Site12") Then Response.Write("disabled")End IF%>>Camp 
   Site 12 <br>
    <input type="checkbox" name="CampSite19" value="Site13" <%If Instr(arrCampSite,"Site13") Then Response.Write("disabled")End IF%>>Camp 
   Site 13 <br>
    <input type="checkbox" name="CampSite20" value="Site14" <%If Instr(arrCampSite,"Site14") Then Response.Write("disabled")End IF%>>Camp 
   Site 14 <br>
    <input type="checkbox" name="CampSite21" value="Site15" <%If Instr(arrCampSite,"Site15") Then Response.Write("disabled")End IF%>>Camp 
   Site 15 <br>
    <input type="checkbox" name="CampSite22" value="Site16" <%If Instr(arrCampSite,"Site16") Then Response.Write("disabled")End IF%>>Camp 
   Site 16 <br>
    <input type="checkbox" name="CampSite23" value="Site17" <%If Instr(arrCampSite,"Site17") Then Response.Write("disabled")End IF%>>Camp 
   Site 17<br>
    <input type="checkbox" name="CampSite24" value="Site18" <%If Instr(arrCampSite,"Site18") Then Response.Write("disabled")End IF%>>Camp 
   Site 18<br>
    <input type="checkbox" name="CampSite25" value="Site19" <%If Instr(arrCampSite,"Site19") Then Response.Write("disabled")End IF%>>Camp 
   Site 19<br>
    <input type="checkbox" name="CampSite26" value="Site20" <%If Instr(arrCampSite,"Site20") Then Response.Write("disabled")End IF%>>Camp 
   Site 20</font></p>
   <p><font size="1"> </font></p>
<p>Contact information <font size="1"><br>
<br>
</font><b><font size="1">FIRST NAME<font color="#FF0000">*</font> </font></b><font size="1"> <input name="FIRSTNAME" size="22" value="" maxlength="255">  
</font><b><font size="1">LAST NAME<font color="#FF0000">*</font>  </font></b><font size="1"> <input name="LASTNAME" size="26" value="" maxlength="255"><br>
<br>
</font><b><font size="1">ADDRESS</font></b><font size="1"><br>
<input name="ADDRESS" size="64" value="" maxlength="255"><br>
</font><b><font size="1"><br>
CITY</font></b><font size="1"><br>
<input name="CITY" size="12" value="" maxlength="255"> 
</font><b><font size="1">PROVINCE</font></b><font size="1"> <input name="PROVINCE" size="13" value="ONTARIO" maxlength="255"></font><b><font size="1">   POSTAL  CODE</font></b><font size="1"> <input name="POSTALCODE" size="7" value="" maxlength="255"> 
</font><b><font size="1"><br>
<br>
PHONE<font color="#FF0000">*</font></font></b><font size="1">
<input name="PHONE" size="22" value="" maxlength="255">  
(519-777-7777)<br>
<br>
</font><b><font size="1"><br>
COUNCIL</font></b><font size="1"><br>
<select size="1" name="REGION">
<option>BATTLEFIELDS</option>
<option>TRI-SHORES</option>
<option>CENTRAL ESCARPMENT</option>
<option>OTHER</option>
</select>   <br>
</font><b><font size="1">AREA  </font></b>
<font size="1"> </font><font face="Arial" size="2"><!--webbot bot="Validation" s-display-name="Please select an area" b-value-required="TRUE" --><select size="1" name="AREA">
                          <option>Please select an area</option>
                          <option>BRANT</option>
                          <option>NIAGARA</option>
						<option>HAMILTON/WENTWORTH</option>
                          <option>FRONTIER</option>
                          <option>WINDSOR</option>
                          <option>ESSEX</option>
                          <option>LONDON</option>
                          <option>ELGIN</option>
                          <option>CHATHAM/KENT</option>
                          <option>BLUEWATER</option>
                          <option>MINDAAMIN</option>
                          <option>SYDENHAM</option>
                          <option>Other not listed</option>
                          <option value="N/A">N/A</option>
                        </select> </font><font face="Arial" size="1">If other 
please specify</font><font face="Arial" size="2"><input type="text" name="AREA" size="29"></font><font size="1"><br>
<br>
</font><b><font size="1">GROUP</font></b><font size="1"><br>
<input name="CAMPGROUP" size="14" 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>
<br>
</font>Numbers that will be attending camp:<font size="1">
</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." I-Maximum-Length="16" --><input name="YOUTH" size="3" 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." I-Maximum-Length="16" --><input name="ADULTS" size="3" value="0" maxlength="16"></font></p>
<p><font size="1">
<br>
</font>
<font face="Arial" size="1">IF NON-SCOUTING PLEASE ENTER THE NAME OF THE ORGANIZATION (i.e.
          VICTORIA PUBLIC SCHOOL) </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">CHECK IN TIME  </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">CHECK OUT TIME</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>
<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">SPECIFICS</font></b><font size="1"><br>
<textarea rows="2" name="SPECIFICS" cols="48"></textarea><br>
<br>
</font>
<b><font size="1">EMAIL<font color="#FF0000">*</font></font></b><font size="1"><br>
<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 color="#FF0000">*</font></font></b><font size="1"><br>
<!--webbot bot="Validation" s-display-name="PASSWORD" b-value-required="TRUE" i-minimum-length="3" i-maximum-length="9" --><input name="PASSWORD" size="18" value="" maxlength="9"><br>
</font>
                    <font size="2">This password is assigned by you and will allow you to go back in
          and view the information you have booked. 
          The password must be a minimum of 3 characters max 9 (can be letters or
          numbers)</font></p>


<p>
                    <font size="2">Changes to information can be made by calling 966-0480 or toll free 1-866-WI-TRI-SCOUTS (1-866-948-7472)
          or
          email <a href="mailto:trishorescamps@scouts.ca" target="_blank">trishorescamps@scouts.ca</a>.</font></p>


   <p><input type="submit" value="Submit" name="B1"></p>
   <input type="hidden" name="DateStart" value="<%=request("DateStart")%>">
	<input type="hidden" name="DateEnd" value="<%=request("DateEnd")%>">
   <input type="hidden" name="CAMP" value="Camp Wetaskiwin">

</form>

(in reply to BeTheBall)
Page:   <<   < prev  1 [2] 3   next >   >>

All Forums >> Web Development >> ASP and Database >> RE: Querying Comma Separated Values
Page: <<   < prev  1 [2] 3   next >   >>
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