Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ASP - Creating an events listings website

Featured Replies

Hi there, am currently creating a site for a local festival later this year. I have built an events database where they fill in the event details (ie: Add new event -click here) and then input the date / name / time / price / full description / image etc.

 

There are 11 categories of type of event (Childrens / Theatre / Music / Cinema etc.) so when adding an event the client pigeon holes the event into one of the 11 categories.

 

All fine with that, and working correctly.

 

Only now they want to be able to put the event into more than one category (ie: a kids film would want to go into Cinema and into Childrens) but without having to duplicate the event in the database.

 

Does anyone know of a way to do this? When submitting an event it passes through the eventid which is held in the events table of the database. The typeid is selected from the dynamic dropdown menu (ie: Children= 1, Theatre = 2) in their admin area.

 

I know there aren't as many ASP coders on this site so if it cannot be done in this way, do you know of any PHP CMS systems that are good for events listings and particuarly for having the same event in multiple categories?

 

Any help most welcome

You just need to add another table, which holds the links between event and category. Can you post your table structures?

 

(e.g.

events:

event_id

event_name

etc

 

and your category table if you have one)

  • Author
You just need to add another table, which holds the links between event and category. Can you post your table structures?

 

(e.g.

events:

event_id

event_name

etc

 

and your category table if you have one)

 

Thanks for that. Here is my current set up

 

tblevents

 

eid (Autonumber - event unque ID)

mid (Number - links to tblcalendar)

event (Text - title of event)

actualdate (Date / Time)

eventdate (Text - in case they want to write extra words for date)

price (Text)

locid (Number - links to tblloc)

typeid (Number - links to tbltype)

eventtime (Text - time of event)

picture (Text - image upload call)

thumb1 (Text - image upload call)

thumb2 (Text - image upload call)

thumb3 (Text - image upload call)

review (Memo - main description of event)

created (Date / Time -when record was created)

ticketlink (Text - direct link to ticket agency website)

 

tblloc

 

locid (Autonumber - location id)

loc (Text - location name) festival has numerous venues

 

tbltype

 

typeid (Autonumber - type id)

typename (Text - type name) Children / Theatre etc.

OK, so you would have a new table for type entries like this:

 

tbltypeentry

 

id (autonumber - to ensure unique records, not used otherwise)

eid (corresponds to eid in tblevents)

typeid (corresponds to typeid in tbltype)

 

And you would remove typeid from tblevents.

 

Each time you create a new event, and some categories are selected, you would create 1 event record, and N typeentry records- each one would have the same eid but the appropriate typeid.

 

To find events in category X, use something like:

 

SELECT tblevents.* FROM tblevents LEFT JOIN tbltypeentry ON tblevents.eid=tbltypeentry.eid WHERE tbltypeentry.typeid=X

 

And to change the categories for an event, simply add/remove appropriate typeentry records. When deleting an event, delete all its typeentry records as well.

 

Does that help you see how it can work? It's not really a question of ASP or PHP being more appropriate, it's all done with the SQL queries.

  • Author

Thanks ZigPress, really helpful.

 

I have created the new table and then removed typed from the tbleevents table.

 

My first task is now in the admin area how do I let the database know what typeid's that event should go into.

 

In my add page I currently have a dynamic drop down menu where they select their one typeid. Presumably I can now create checkboxes with all categories listed so they can add that event to as many categories as they wish?

 

Would each checkbox need to be called 'typeid' then have the values as 1 - 11?

 

My add page goes direct to a parse page (for the image uploads) and the current contents includes:

 <%
set rsadd = Server.CreateObject("ADODB.Recordset")
rsadd.ActiveConnection = MM_myname_STRING
rsadd.Source = "SELECT *  FROM tblevents"
rsadd.CursorType = 0
rsadd.CursorLocation = 2
rsadd.LockType = 3
rsadd.Open()
rsadd_numRows = 0
%>
<%
rsadd.addnew
rsadd ("typeid") = mysmartupload.form ("typeid")
rsadd ("mid") = mysmartupload.form ("mid")
rsadd ("event") = mysmartupload.form ("event")
rsadd ("actualdate") = mysmartupload.form ("actualdate")
rsadd ("eventdate") = mysmartupload.form ("eventdate")
rsadd ("price") = mysmartupload.form ("price")
rsadd ("locid") = mysmartupload.form ("locid")
rsadd ("eventtime") = mysmartupload.form( "eventtime")
rsadd ("picture") = image
rsadd ("thumb1") = image2
rsadd ("thumb2") = image3
rsadd ("thumb3") = image4
rsadd ("review") = mysmartupload.form ("review")
rsadd ("created") = date()
rsadd ("ticketlink") = mysmartupload.form ("ticketlink")
rsadd.update
%>
<%
Response.Redirect "../confirm.asp"
%>

 

So I would need to take out the typeid at the top and replace that with?

The ASP code will need to read the checkbox values as an array. You're right that you should give the form elements the same name and different values.

 

Here's a code segment which shows you how to code the array reading bit. You would then insert a typeentry record for each value you got from the array.

 

for i = 0 to Request.Form("typeid").length - 1
	valueToInsert = Request.Form("typeid").item(i)
	' do your insert here
next

  • Author

Thanks again, getting there I think.

 

So on the Add page (which submits to the add_event_parse.asp page)

 

I have put this where the drop-downs were:

<label>
<input type="checkbox" name="tbltype" value="1" id="tbltype">Children</label>
<br>
<label>
<input type="checkbox" name="tbltype" value="2" id="tbltype">Drama</label>
<br>
<label>
<input type="checkbox" name="tbltype" value="3" id="tbltype">Exhibitions</label>
<br>
<label>
<input type="checkbox" name="tbltype" value="4" id="tbltype">Family & Community</label>
<br>
<label>
<input type="checkbox" name="tbltype" value="5" id="tbltype">Film</label>

 

So would your array code (not come across these bfore so excuse myignorance) go on the add.asp page or the actual parse page?

 

Also on the parse page I presume I need to amend it from

 

<%
set rsadd = Server.CreateObject("ADODB.Recordset")
rsadd.ActiveConnection = MM_myname_STRING
rsadd.Source = "SELECT *  FROM tblevents"
rsadd.CursorType = 0
rsadd.CursorLocation = 2
rsadd.LockType = 3
rsadd.Open()
rsadd_numRows = 0
%>

 

to

 

<%
set rsadd = Server.CreateObject("ADODB.Recordset")
rsadd.ActiveConnection = MM_myname_STRING
rsadd.Source = "SELECT *  FROM tblevents, tbltypeentry"
rsadd.CursorType = 0
rsadd.CursorLocation = 2
rsadd.LockType = 3
rsadd.Open()
rsadd_numRows = 0
%>

 

so that tbltypeentry is referenced in the recordset?

OK, let's square away the terminology: I'm interpreting your post to mean that your "add" page is the form to input an event, and your "parse" page is the code to inject that event into the database.

 

Your add page can use SQL to display the checkboxes (saves doing them manually):

 

<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open YOUR_CONNECTION_STRING
sql = "SELECT * FROM tbltype ORDER BY typename ASC "
set RS = conn.execute(sql)
if not(RS.BOF and RS.EOF) then
do while not RS.EOF
	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=RS("typeid")%>" /> <%=RS("typename")%>
	</div>
	<%
loop
end if
RS.close
set RS = nothing
%>

 

See if you can get that working, then we'll deal with the parse page.

  • Author

Cheers again, and for recommending CS New Media - I signed up for them last week after reading your thoughts on them. Great so far for me.

 

Yes you presume correct in that the Add page then points to a parse page to process the data.

 

Just added your code where my checkboxes were (replacing 'RS' with 'rstype' which is my recordset name, and putting the correct connection string)

 

but it is coming up with this when I try to load the page.

 

Response object error 'ASP 0251 : 80004005'

 

Response Buffer Limit Exceeded

 

/admin/events/add_event3.asp, line 0

 

Execution of the ASP page caused the Response Buffer to exceed its configured limit.

 

My actual code for the add page in full (with your posted code) is here:

 

<%@LANGUAGE="VBSCRIPT"%> 
<!--#include file="../../Connections/MYCONNECTIONNAME.asp" -->
<%
set rsmonth = Server.CreateObject("ADODB.Recordset")
rsmonth.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsmonth.Source = "SELECT *  FROM tblcalendar"
rsmonth.CursorType = 0
rsmonth.CursorLocation = 2
rsmonth.LockType = 3
rsmonth.Open()
rsmonth_numRows = 0
%>
<%
Dim rsadd
Dim rsadd_cmd
Dim rsadd_numRows

Set rsadd_cmd = Server.CreateObject ("ADODB.Command")
rsadd_cmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsadd_cmd.CommandText = "SELECT * FROM tblevents" 
rsadd_cmd.Prepared = true

Set rsadd = rsadd_cmd.Execute
rsadd_numRows = 0
%>
<%
set rsloc = Server.CreateObject("ADODB.Recordset")
rsloc.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsloc.Source = "SELECT *  FROM tblloc"
rsloc.CursorType = 0
rsloc.CursorLocation = 2
rsloc.LockType = 3
rsloc.Open()
rsloc_numRows = 0
%>
<%
Dim rstype
Dim rstype_cmd
Dim rstype_numRows

Set rstype_cmd = Server.CreateObject ("ADODB.Command")
rstype_cmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rstype_cmd.CommandText = "SELECT * FROM tbltype" 
rstype_cmd.Prepared = true

Set rstype = rstype_cmd.Execute
rstype_numRows = 0
%>
<%
Dim rstypeentry
Dim rstypeentry_cmd
Dim rstypeentry_numRows

Set rstypeentry_cmd = Server.CreateObject ("ADODB.Command")
rstypeentry_cmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rstypeentry_cmd.CommandText = "SELECT * FROM tbltypeentry" 
rstypeentry_cmd.Prepared = true

Set rstypeentry = rstypeentry_cmd.Execute
rstypeentry_numRows = 0
%>
<html>
<head>
<title>Database - Add Event</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr> 
<td valign="top" align="center"> <br>
  <table width="100%" border="0" cellspacing="0" cellpadding="6">
	<tr> 
	  <td align="center"> <span class="style1">Database Administration  
		</span><b>- <a href="../admin.asp" class="style2">return 
		to main menu</a></b> 
		<form name="form1" method="post" action="add_event_parse2.asp" enctype="multipart/form-data">
		  <table border="0" cellspacing="2" cellpadding="2">
			<tr> 
			  <td width="120" valign="top"><b>ADD 
				EVENT </b></td>
			  <td> 
				<div align="right"><a href="java script:history.back()"></a><a href="java script:history.back()" class="style3">< previous page</a></div>				  </td>
			</tr>
			<tr> 
			  <td width="120" valign="top"><b></b></td>
			  <td width="273"> </td>
			</tr>
			<tr>
			  <td valign="top" bgcolor="#666699"><b>> 
			  type of event </b></td>
			  <td bgcolor="#DFDFEA"><p>
			  <%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open MM_MYCONNECTIONNAME_STRING
sql = "SELECT * FROM tbltype ORDER BY typename ASC "
set rstype = conn.execute(sql)
if not(rstype.BOF and rstype.EOF) then
do while not rstype.EOF
	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=rstype("typeid")%>" /> <%=rstype("typename")%>
	</div>
	<%
loop
end if
rstype.close
set rstype = nothing
%><br>
			  </p></td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				day of event</b></td>
			  <td bgcolor="#DFDFEA"> 
				<select name="mid">
				  <option selected>Please Select</option>
				  <%
While (NOT rsmonth.EOF)
%>
				  <option value="<%=(rsmonth.Fields.Item("mid").Value)%>"><%=(rsmonth.Fields.Item("m").Value)%></option>
				  <%
 rsmonth.MoveNext()
Wend
If (rsmonth.CursorType > 0) Then
 rsmonth.MoveFirst
Else
 rsmonth.Requery
End If
%>
			  </select>				  </td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				event</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="text" name="event" size="45" maxlength="250">				  </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				actual date</b></td>
			  <td bgcolor="#DFDFEA">
				<input type="text" name="actualdate">
				<span class="style4"><b>(DD/MM/YYYY) 
			  </b>				  If more than one day please use 1st date</span></td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				displayed date</b></td>
			  <td bgcolor="#DFDFEA"> 
				<input type="text" name="eventdate" size="30" maxlength="40">
				<span class="style4">what 
			  the User will see online</span></td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				price</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="text" name="price" size="30" maxlength="60">				  </td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				location</b></td>
			  <td bgcolor="#DFDFEA"> 
				<select name="locid">
				  <option selected>Please Select</option>
				  <%
While (NOT rsloc.EOF)
%>
				  <option value="<%=(rsloc.Fields.Item("locid").Value)%>"><%=(rsloc.Fields.Item("loc").Value)%></option>
				  <%
 rsloc.MoveNext()
Wend
If (rsloc.CursorType > 0) Then
 rsloc.MoveFirst
Else
 rsloc.Requery
End If
%>
			  </select>				  </td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				event time</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="text" name="eventtime" size="30" maxlength="15" value="8pm">				  </td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				picture</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="file" name="picture" size="20">
			  <span class="style6">(200 pixels wide maximum) </span> </td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				thumbnail 1 </b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="file" name="thumb1" size="20">
			  <span class="style6">(120 x 120 pixels wide)				   </span></td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				thumbnail 2</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="file" name="thumb2" size="20">
			  <span class="style6">(400 pixels wide maximum)</span> </td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				thumbnail 3</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="file" name="thumb3" size="20">
			  <span class="style6">(400 pixels wide maximum)</span> </td>
			</tr>
			<tr> 
			  <td width="120" valign="top" bgcolor="#666699"><b>> 
				review 
				<input type="hidden" name="created" value="<%=date()%>">
				</b></td>
			  <td bgcolor="#DFDFEA"><span style="padding:0px">
				<textarea name="review" cols="70" rows="20" wrap="soft" id="review" style="width:100%"></textarea>
			  </span></td>
			</tr>
			<tr>
			  <td valign="top" bgcolor="#666699"><b>> ticketweb link </b></td>
			  <td bgcolor="#DFDFEA"><input name="ticketlink" type="text" id="ticketlink" size="45" maxlength="250">
			  <span class="style6">(Direct link to the event on Ticket Web)</span></td>
			</tr>
			<tr align="center"> 
			  <td colspan="2">  
				<input type="submit" name="add" value="<< add event >>">
				</td>
			</tr>
		  </table>
		</form>
	  </td>
	</tr>
  </table>
</td>
 </tr>
</table>
</body>
</html>
<%
rsmonth.Close()
%>
<%
rsadd.Close()
%>
<%
rsloc.Close()
%>
<%
rstype.Close()
Set rstype = Nothing
%>
<%
rstypeentry.Close()
Set rstypeentry = Nothing
%>

OK, I think that's because you're using recordset objects, whereas I normally work with plain connection objects.

 

Give me a few minutes and I'll post back some revisions.

Try this (keep your older versions as a backup!). You already had a stored procedure to retrieve the types, so I just used that instead.

 

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../Connections/MYCONNECTIONNAME.asp" -->
<%
set rsmonth = Server.CreateObject("ADODB.Recordset")
rsmonth.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsmonth.Source = "SELECT *  FROM tblcalendar"
rsmonth.CursorType = 0
rsmonth.CursorLocation = 2
rsmonth.LockType = 3
rsmonth.Open()
rsmonth_numRows = 0
%>
<%
Dim rsadd
Dim rsadd_cmd
Dim rsadd_numRows

Set rsadd_cmd = Server.CreateObject ("ADODB.Command")
rsadd_cmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsadd_cmd.CommandText = "SELECT * FROM tblevents"
rsadd_cmd.Prepared = true

Set rsadd = rsadd_cmd.Execute
rsadd_numRows = 0
%>
<%
set rsloc = Server.CreateObject("ADODB.Recordset")
rsloc.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsloc.Source = "SELECT *  FROM tblloc"
rsloc.CursorType = 0
rsloc.CursorLocation = 2
rsloc.LockType = 3
rsloc.Open()
rsloc_numRows = 0
%>
<%
Dim rstype
Dim rstype_cmd
Dim rstype_numRows

Set rstype_cmd = Server.CreateObject ("ADODB.Command")
rstype_cmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rstype_cmd.CommandText = "SELECT * FROM tbltype"
rstype_cmd.Prepared = true

Set rstype = rstype_cmd.Execute
rstype_numRows = 0
%>
<html>
<head>
<title>Database - Add Event</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
<td valign="top" align="center"> <br>
  <table width="100%" border="0" cellspacing="0" cellpadding="6">
	<tr>
	  <td align="center"> <span class="style1">Database Administration  
		</span><b>- <a href="../admin.asp" class="style2">return
		to main menu</a></b>
		<form name="form1" method="post" action="add_event_parse2.asp" enctype="multipart/form-data">
		  <table border="0" cellspacing="2" cellpadding="2">
			<tr>
			  <td width="120" valign="top"><b>ADD
				EVENT </b></td>
			  <td>
				<div align="right"><a href="java script:history.back()"></a><a href="java script:history.back()" class="style3">< previous page</a></div>				  </td>
			</tr>
			<tr>
			  <td width="120" valign="top"><b></b></td>
			  <td width="273"> </td>
			</tr>
			<tr>
			  <td valign="top" bgcolor="#666699"><b>>
			  type of event </b></td>
			  <td bgcolor="#DFDFEA"><p>
			  <%
While (NOT rstype.EOF)
	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=rstype.Fields.Item("typeid").Value%>" /> <%=rstype.Fields.Item("typename").Value%>
	</div>
	<%
 rstype.MoveNext()
Wend
If (rstype.CursorType > 0) Then
 rstype.MoveFirst
Else
 rstype.Requery
End If
%><br>
			  </p></td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				day of event</b></td>
			  <td bgcolor="#DFDFEA">
				<select name="mid">
				  <option selected>Please Select</option>
				  <%
While (NOT rsmonth.EOF)
%>
				  <option value="<%=(rsmonth.Fields.Item("mid").Value)%>"><%=(rsmonth.Fields.Item("m").Value)%></option>
				  <%
 rsmonth.MoveNext()
Wend
If (rsmonth.CursorType > 0) Then
 rsmonth.MoveFirst
Else
 rsmonth.Requery
End If
%>
			  </select>				  </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				event</b></td>
			  <td bgcolor="#DFDFEA">
			  <input type="text" name="event" size="45" maxlength="250">				  </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				actual date</b></td>
			  <td bgcolor="#DFDFEA">
				<input type="text" name="actualdate">
				<span class="style4"><b>(DD/MM/YYYY)
			  </b>				  If more than one day please use 1st date</span></td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				displayed date</b></td>
			  <td bgcolor="#DFDFEA">
				<input type="text" name="eventdate" size="30" maxlength="40">
				<span class="style4">what
			  the User will see online</span></td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				price</b></td>
			  <td bgcolor="#DFDFEA">
			  <input type="text" name="price" size="30" maxlength="60">				  </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				location</b></td>
			  <td bgcolor="#DFDFEA">
				<select name="locid">
				  <option selected>Please Select</option>
				  <%
While (NOT rsloc.EOF)
%>
				  <option value="<%=(rsloc.Fields.Item("locid").Value)%>"><%=(rsloc.Fields.Item("loc").Value)%></option>
				  <%
 rsloc.MoveNext()
Wend
If (rsloc.CursorType > 0) Then
 rsloc.MoveFirst
Else
 rsloc.Requery
End If
%>
			  </select>				  </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				event time</b></td>
			  <td bgcolor="#DFDFEA">
			  <input type="text" name="eventtime" size="30" maxlength="15" value="8pm">				  </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				picture</b></td>
			  <td bgcolor="#DFDFEA">
			  <input type="file" name="picture" size="20">
			  <span class="style6">(200 pixels wide maximum) </span> </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				thumbnail 1 </b></td>
			  <td bgcolor="#DFDFEA">
			  <input type="file" name="thumb1" size="20">
			  <span class="style6">(120 x 120 pixels wide)				   </span></td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				thumbnail 2</b></td>
			  <td bgcolor="#DFDFEA">
			  <input type="file" name="thumb2" size="20">
			  <span class="style6">(400 pixels wide maximum)</span> </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				thumbnail 3</b></td>
			  <td bgcolor="#DFDFEA">
			  <input type="file" name="thumb3" size="20">
			  <span class="style6">(400 pixels wide maximum)</span> </td>
			</tr>
			<tr>
			  <td width="120" valign="top" bgcolor="#666699"><b>>
				review
				<input type="hidden" name="created" value="<%=date()%>">
				</b></td>
			  <td bgcolor="#DFDFEA"><span style="padding:0px">
				<textarea name="review" cols="70" rows="20" wrap="soft" id="review" style="width:100%"></textarea>
			  </span></td>
			</tr>
			<tr>
			  <td valign="top" bgcolor="#666699"><b>> ticketweb link </b></td>
			  <td bgcolor="#DFDFEA"><input name="ticketlink" type="text" id="ticketlink" size="45" maxlength="250">
			  <span class="style6">(Direct link to the event on Ticket Web)</span></td>
			</tr>
			<tr align="center">
			  <td colspan="2">  
				<input type="submit" name="add" value="<< add event >>">
				</td>
			</tr>
		  </table>
		</form>
	  </td>
	</tr>
  </table>
</td>
 </tr>
</table>
</body>
</html>
<%
rsmonth.Close()
%>
<%
rsadd.Close()
%>
<%
rsloc.Close()
%>
<%
rstype.Close()
%>

  • Author

Excellent, many thanks - now that is showing the add page and all of the checkboxes have been pulled in.

 

Now here is my parse page code in full (before I made any amendments):

<%@LANGUAGE="VBSCRIPT"%> 
<!--#include file="../../Connections/MYCONNECTIONNAME.asp" -->

<% Response.Buffer = true %>
<!-- #include file = "../adovbs.inc" -->
<%
randomize
randomnum1=int(rnd*9999999) + 1
%>

<%
'  Variables 
'  *********	
Dim mySmartUpload	
Dim file	
Dim intCount
Dim nametag	
intCount = 1	  

'  Object creation 
'  ***************	
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")  

'  Upload 
'  ******	
mySmartUpload.Upload  

'  Select each file 
'  ****************	
' For each file In mySmartUpload.Files

'  Only if the file exist	
'  **********************	   
%>
<%
dim image, image2, image3, image4
%>
<%
If not mySmartUpload.files.item(1).IsMissing Then 
image =  randomnum1 & "_1." & mysmartupload.files.item(1).fileext
mysmartUpload.files.item(1).saveas "../../uploads/" & image
response.write image
end if 
%>

<%
If not mySmartUpload.files.item(2).IsMissing Then 
image2 =  randomnum1 & "_2." & mysmartupload.files.item(2).fileext
mysmartUpload.files.item(2).saveas "../../uploads/" & image2
response.write image2
end if 
%>

<%
If not mySmartUpload.files.item(3).IsMissing Then 
image3 =  randomnum1 & "_3." & mysmartupload.files.item(3).fileext
mysmartUpload.files.item(3).saveas "../../uploads/" & image3
response.write image3
end if 
%>
<%
If not mySmartUpload.files.item(4).IsMissing Then 
image4 =  randomnum1 & "_4." & mysmartupload.files.item(4).fileext
mysmartUpload.files.item(4).saveas "../../uploads/" & image4
response.write image4
end if 
%>

<%
set rsadd = Server.CreateObject("ADODB.Recordset")
rsadd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsadd.Source = "SELECT *  FROM tblevents"
rsadd.CursorType = 0
rsadd.CursorLocation = 2
rsadd.LockType = 3
rsadd.Open()
rsadd_numRows = 0
%>
<%
rsadd.addnew
rsadd ("typeid") = mysmartupload.form ("typeid")
rsadd ("mid") = mysmartupload.form ("mid")
rsadd ("event") = mysmartupload.form ("event")
rsadd ("actualdate") = mysmartupload.form ("actualdate")
rsadd ("eventdate") = mysmartupload.form ("eventdate")
rsadd ("price") = mysmartupload.form ("price")
rsadd ("locid") = mysmartupload.form ("locid")
rsadd ("eventtime") = mysmartupload.form( "eventtime")
rsadd ("picture") = image
rsadd ("thumb1") = image2
rsadd ("thumb2") = image3
rsadd ("thumb3") = image4
rsadd ("review") = mysmartupload.form ("review")
rsadd ("created") = date()
rsadd ("ticketlink") = mysmartupload.form ("ticketlink")
rsadd.update
%>
<%
Response.Redirect "../confirm.asp"
%>

<%
rsadd.Close()
%>

 

Presume somewhere on here I need to reference the fact that the typeid is now coming from the tbltypeentry table and not from the tblevents table as previous?

OK glad that worked... I hardly do any ASP coding these days (almost all PHP) so I'm a bit rusty :)

 

Basically what you need to do is what I hinted at earlier - instead of adding a single typeid to the event record, you're going to create a number of typeentry records.

 

Firstly remove this line:

rsadd ("typeid") = mysmartupload.form ("typeid")

 

Then after the rsadd.addnew add the line:

eid = rsadd ("eid")

 

Then near the end of the file, before the response.redirect, we add the stuff to create those records:

<%
dim rsentries, i
set rsentries = Server.CreateObject("ADODB.Recordset")
rsentries.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsentries.Source = "SELECT *  FROM tbltypeentry"
rsentries.CursorType = 0
rsentries.CursorLocation = 2
rsentries.LockType = 3
rsentries.Open()
rsentries_numRows = 0
for i = 0 to mysmartupload.form("typeid").length - 1
rsentries.addnew
rsentries("eid") = eid
rsentries("typeid") = mysmartupload.form("typeid").item(i)
rsentries.update
next
rsentries.Close()
%>

 

I think that should do it... the bit I'm not certain about is whether trying to get the new event id just after the addnew will actually work, because as I said earlier, I never used to use recordsets for inserts and updates - only selects.

  • Author

Thanks for all your help on this and your time.

 

Just tried that and get this error on the parse page:

 

2997706_1.gif

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'form(...).length'

/admin/events/add_event_parse4.asp, line 108

 

The image seems to have gone up OK (can see the randomly generated filename)

 

but failing on line 108 which is:

for i = 0 to mysmartupload.form("typeid").length - 1

Bugger. I'm now in "relax with girlfriend at home" mode, however I will look at it tomorrow.

 

Meanwhile, please can you post a URL where I can find documentation on the "mysmartupload" component you're using?

 

Thanks.

  • Author
Bugger. I'm now in "relax with girlfriend at home" mode, however I will look at it tomorrow.

 

Meanwhile, please can you post a URL where I can find documentation on the "mysmartupload" component you're using?

 

Thanks.

 

Cheers for that, it uses ASPSmartUpload on the server. It is quite old but i've been using it for years. It uploads the image for you into an uploads folder and puts the file name into the database.

 

Here is a link to it's Setup Instructions

It's really hard to find good documentation on it... but found some in the end. Try changing "length" to "count" on that line.

  • Author
It's really hard to find good documentation on it... but found some in the end. Try changing "length" to "count" on that line.

 

 

Cheers, just tried that and line 111 is erroring

 

4516870_1.gif

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'form(...).item'

/admin/events/add_event_parse4.asp, line 111

 

Line 111 is

	rsentries("typeid") = mysmartupload.form("typeid").item(i)

Hi,

 

OK, after a quick dig, try replacing:

 

for i = 0 to mysmartupload.form("typeid").length - 1
rsentries.addnew
rsentries("eid") = eid
rsentries("typeid") = mysmartupload.form("typeid").item(i)
rsentries.update
next

with:

for each item in mysmartupload.form("typeid")
rsentries.addnew
rsentries("eid") = eid
rsentries("typeid") = item
rsentries.update
next

  • Author

Superb - went in a treat. Selected 3 categories on the add form when submitting.

 

Downloaded the DB file and in the tbltypeentry there is the following:

 

id eid typeid

10 16 1

11 16 4

12 16 7

 

Can't thank you enough. My next step will be working out how to put this into the edit event database page and then into the results pages on the live site. With your help I should be able to get it sorted. Will post back if I get stuck.

 

Thanks again

You're very welcome. Note: some days I have more time available to help forum members than others...

  • Author

Just looking at the 'Edit Event' page now.

 

On the edit form I have pulled in the code you suggested:

 

	<%
While (NOT rstype.EOF)
	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=rstype.Fields.Item("typeid").Value%>" /> <%=rstype.Fields.Item("typename").Value%>
	</div>
	<%
 rstype.MoveNext()
Wend
If (rstype.CursorType > 0) Then
 rstype.MoveFirst
Else
 rstype.Requery
End If
%>

 

And all the categories are displayed unchecked, but I need it to display the events that were selected in the Add event page.

 

With all the other form fields I do this:

 

<input type="text" name="actualdate" value="<%=(rsedit.Fields.Item("actualdate").Value)%>">

 

So not sure how to do it for the checkboxes.

 

I then need to be able to amend the choices for type and any other amendements to the other fields and hit submit.

 

The form should then update.

 

I have been playing around with the code but can't seem to carry over the values for the typeid which are held in the tbltypeentry table.

 

On the edit page I have created a new recordset for tbltypeentry but no joy.

 

The edit page doesn't use MySmartUpload at all as the images link off to separate pages.

 

Code I am using so far:

 

<%@LANGUAGE="VBSCRIPT"%> 
<!--#include file="../../Connections/MYCONNECTIONNAME.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
 MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
 If condition = "" Then
MM_IIf = ifFalse
 Else
MM_IIf = ifTrue
 End If
End Function
%>
<%
If (CStr(Request("MM_update")) = "form1") Then
 If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
MM_editCmd.CommandText = "UPDATE tblevents SET mid = ?, event = ?, actualdate = ?, eventdate = ?, price = ?, locid = ?, eventtime = ?, review = ?, ticketlink = ? WHERE eid = ?" 
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("month"), Request.Form("month"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 250, Request.Form("artist")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 135, 1, -1, MM_IIF(Request.Form("actualdate"), Request.Form("actualdate"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 40, Request.Form("eventdate")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 60, Request.Form("price")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 5, 1, -1, MM_IIF(Request.Form("locid"), Request.Form("locid"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 15, Request.Form("eventtime")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 203, 1, 1073741823, Request.Form("review")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 203, 1, 1073741823, Request.Form("ticketlink")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "../confirm.asp"
If (Request.QueryString <> "") Then
  If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
	MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
  Else
	MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
  End If
End If
Response.Redirect(MM_editRedirectUrl)
 End If
End If
%>
<%
set rsmonth = Server.CreateObject("ADODB.Recordset")
rsmonth.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsmonth.Source = "SELECT mid, m  FROM tblcalendar"
rsmonth.CursorType = 0
rsmonth.CursorLocation = 2
rsmonth.LockType = 3
rsmonth.Open()
rsmonth_numRows = 0
%>
<%
Dim rsedit__varid
rsedit__varid = "0"
if (Request.QueryString("eid") <> "") then rsedit__varid = Request.QueryString("eid")
%>
<%
Dim rsedit
Dim rsedit_cmd
Dim rsedit_numRows

Set rsedit_cmd = Server.CreateObject ("ADODB.Command")
rsedit_cmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsedit_cmd.CommandText = "SELECT eid, mid, event, actualdate, eventdate, price, locid, eventtime, picture, thumb1, thumb2, thumb3, review, created, ticketlink FROM tblevents WHERE eid = ?" 
rsedit_cmd.Prepared = true
rsedit_cmd.Parameters.Append rsedit_cmd.CreateParameter("param1", 5, 1, -1, rsedit__varid) ' adDouble

Set rsedit = rsedit_cmd.Execute
rsedit_numRows = 0
%>
<%
set rsloc = Server.CreateObject("ADODB.Recordset")
rsloc.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rsloc.Source = "SELECT locid, loc  FROM tblloc"
rsloc.CursorType = 0
rsloc.CursorLocation = 2
rsloc.LockType = 3
rsloc.Open()
rsloc_numRows = 0
%>
<%
Dim rstype
Dim rstype_cmd
Dim rstype_numRows

Set rstype_cmd = Server.CreateObject ("ADODB.Command")
rstype_cmd.ActiveConnection = MM_MYCONNECTIONNAME_STRING
rstype_cmd.CommandText = "SELECT * FROM tbltype" 
rstype_cmd.Prepared = true

Set rstype = rstype_cmd.Execute
rstype_numRows = 0
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
 NextItem = "&" & Item & "="
 If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
 End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
 NextItem = "&" & Item & "="
 If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
 End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "")  Then MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
 If (firstItem <> "") Then
MM_joinChar = "&"
 Else
MM_joinChar = ""
 End If
End Function
%>
<html>
<head>
<title>Database - Edit Event</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0">

  <table width="100%" border="0" cellspacing="0" cellpadding="6">
	<tr> 
	  <td align="center"> <span class="style2">Database Administration</span> <b></b> 
		<b>- <a href="../admin.asp" class="style4">return 
		to main menu</a><a href="../admin.asp"></a></b> 
		<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1">
		  <table width="50%" border="0" align="center" cellpadding="2" cellspacing="2">
			<tr> 
			  <td><b>EDIT 
				EVENT </b></td>
			  <td> 
				<div align="right"><a href="java script:history.back()" class="style3">< previous page</a></div>				  </td>
			</tr>
			<tr> 
			  <td><b></b></td>
			  <td> </td>
			</tr>
			<tr>
			  <td bgcolor="#666699" valign="top"><b>type</b></td>
			  <td bgcolor="#DFDFEA">	<%
While (NOT rstype.EOF)
	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=rstype.Fields.Item("typeid").Value%>" /> <%=rstype.Fields.Item("typename").Value%>
	</div>
	<%
 rstype.MoveNext()
Wend
If (rstype.CursorType > 0) Then
 rstype.MoveFirst
Else
 rstype.Requery
End If
%></td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>month</b></td>
			  <td bgcolor="#DFDFEA"> 
				<select name="month">
				  <option selected>Please Select</option>
				  <%
While (NOT rsmonth.EOF)
%>
				  <option value="<%=(rsmonth.Fields.Item("mid").Value)%>" <%if (CStr(rsmonth.Fields.Item("mid").Value) = CStr(rsedit.Fields.Item("mid").Value)) then Response.Write("SELECTED") : Response.Write("")%> ><%=(rsmonth.Fields.Item("m").Value)%></option>
				  <%
 rsmonth.MoveNext()
Wend
If (rsmonth.CursorType > 0) Then
 rsmonth.MoveFirst
Else
 rsmonth.Requery
End If
%>
			  </select>				  </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>event</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="text" name="artist" size="45" maxlength="100" value="<%=(rsedit.Fields.Item("event").Value)%>">				  </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>actual 
				date </b></td>
			  <td bgcolor="#DFDFEA"> 
				<input type="text" name="actualdate" value="<%=(rsedit.Fields.Item("actualdate").Value)%>">
				<span class="style1">(DD/MM/YYYY) 
				</span></td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>displayed 
				date</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="text" name="eventdate" size="35" maxlength="40" value="<%=(rsedit.Fields.Item("eventdate").Value)%>">				  </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>price</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="text" name="price" size="35" maxlength="60" value="<%=(rsedit.Fields.Item("price").Value)%>">				  </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>location</b></td>
			  <td bgcolor="#DFDFEA"> 
				<select name="locid">
				  <option selected>Please Select</option>
				  <%
While (NOT rsloc.EOF)
%>
				  <option value="<%=(rsloc.Fields.Item("locid").Value)%>" <%if (CStr(rsloc.Fields.Item("locid").Value) = CStr(rsedit.Fields.Item("locid").Value)) then Response.Write("SELECTED") : Response.Write("")%> ><%=(rsloc.Fields.Item("loc").Value)%></option>
				  <%
 rsloc.MoveNext()
Wend
If (rsloc.CursorType > 0) Then
 rsloc.MoveFirst
Else
 rsloc.Requery
End If
%>
			  </select>				  </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>event 
				time</b></td>
			  <td bgcolor="#DFDFEA"> 
			  <input type="text" name="eventtime" size="35" maxlength="15" value="<%=(rsedit.Fields.Item("eventtime").Value)%>">				  </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>picture</b></td>
			  <td bgcolor="#DFDFEA"><img src="../../uploads/<%=(rsedit.Fields.Item("picture").Value)%>"><br>
				<a href="edit_picture.asp?<%= MM_keepURL %>"><b>(CLICK 
			  HERE TO EDIT)</b></a> </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>thumb 
				1 </b></td>
			  <td bgcolor="#DFDFEA"><img src="../../uploads/<%=(rsedit.Fields.Item("thumb1").Value)%>"><br>
				<a href="edit_picture.asp?<%= MM_keepURL %>"><b>(CLICK 
			  HERE TO EDIT)</b></a> </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>thumb 
				2</b></td>
			  <td bgcolor="#DFDFEA"><img src="../../uploads/<%=(rsedit.Fields.Item("thumb2").Value)%>"><br>
				<a href="edit_picture.asp?<%= MM_keepURL %>"><b>(CLICK 
			  HERE TO EDIT)</b></a> </td>
			</tr>
			<tr> 
			  <td width="120" bgcolor="#666699" valign="top"><b>thumb 
				3 <br>
				</b></td>
			  <td bgcolor="#DFDFEA"> <img src="../../uploads/<%=(rsedit.Fields.Item("thumb3").Value)%>"><br>
				<A HREF="edit_picture.asp?<%= MM_keepURL %>"><b>(CLICK 
			  HERE TO EDIT)</b></A> </td>
			</tr>
			<tr>
			  <td valign="top" bgcolor="#666699"><b>> 
			  review				  </b></td>
			  <td bgcolor="#DFDFEA"><span style="padding:0px">
				<textarea name="review" cols="70" rows="20" wrap="soft" id="review" style="width:100%"><%=(rsedit.Fields.Item("review").Value)%></textarea>
			  </span></td>
			</tr>
			<tr>
			  <td bgcolor="#666699" valign="top"><b>ticketlink</b></td>
			  <td bgcolor="#DFDFEA"><input name="ticketlink" type="text" id="ticketlink" value="<%=(rsedit.Fields.Item("ticketlink").Value)%>" size="45" maxlength="100"></td>
			</tr>
			<tr> 
			  <td colspan="2" bgcolor="#003333" height="2"></td>
			</tr>
			<tr align="center"> 
			  <td colspan="2"><b></b> 
				<input type="submit" name="edit" value="<< edit event >>">
				<a href="eventslist.asp"></a></td>
			</tr>
		  </table>
		  <input type="hidden" name="MM_recordId" value="<%= rsedit.Fields.Item("eid").Value %>">
		  <input type="hidden" name="MM_update" value="form1">
</form>
	  </td>
	</tr>
  </table>

</body>
</html>
<%
rsmonth.Close()
%>
<%
rsedit.Close()
%>
<%
rsloc.Close()
%>
<%
rstype.Close()
%>

 

This pulls in all the data into the fields of the eidt page that I added on the add page apart from the type. Just need to

 

1. Show which types were selected when adding

2. Be able to amend the selections.

 

Once i've cracked this I should be fine. Thanks in advance if anyone can help me, much appreciated.

Hi,

 

Each time you show a checkbox, you need to see if there is an entry for it in the typeentries table.

 

You can do it by replacing this:

 

While (NOT rstype.EOF)
	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=rstype.Fields.Item("typeid").Value%>" /> <%=rstype.Fields.Item("typename").Value%>
	</div>
	<%
 rstype.MoveNext()
Wend

With this:

 

dim checked, rstypeentry, rstypeentry_numRows
While (NOT rstype.EOF)

	'here we check if each type has an entry for this event
	checked = ""
	set rstypentry = Server.CreateObject("ADODB.Recordset")
	rstypentry.ActiveConnection = MM_MYCONNECTIONNAME_STRING
	rstypentry.Source = "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "
	rstypentry.CursorType = 0
	rstypentry.CursorLocation = 2
	rstypentry.LockType = 3
	rstypentry.Open()
	rstypentry_numRows = 0

	if (not rstypeentry.EOF) then checked = " checked='checked' "

	rstypeentry.Close()
	set rstypeentry = nothing

	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=rstype.Fields.Item("typeid").Value%>" <%=checked%> /> <%=rstype.Fields.Item("typename").Value%>
	</div>
	<%
 rstype.MoveNext()
Wend

 

As always, not tested because I'm not running IIS at the moment - but I think it looks OK.

  • Author

Excellent, thanks for the response.

 

Throwing up this error on line 193

 

Microsoft VBScript runtime  error '800a01a8'

Object required: ''

/admin/events/edit.asp, line 193

 

where 193 is

 

		if (not rstypeentry.EOF) then checked = " checked='checked' "

Can you insert

 

response.write "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "

on its own line just after rstypentry_numRows = 0

 

and tell me what is shown?

  • Author
Can you insert

 

response.write "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "

on its own line just after rstypentry_numRows = 0

 

and tell me what is shown?

 

 

Just added that and now get this:

 

SELECT id FROM tbltypeentry WHERE (eid=18) AND (typeid=1)

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/admin/events/edit.asp, line 194

 

where 194 is

 

		if (not rstypeentry.EOF) then checked = " checked='checked' "

One more question... the three fields in that SQL statement should be the names of the three fields in the tbltypeentry table. Did I get them right?

  • Author
One more question... the three fields in that SQL statement should be the names of the three fields in the tbltypeentry table. Did I get them right?

 

Yes the tbltypeentry table has the following fields:

 

id

eid

typeid

Hmm OK... try replacing:

 

		'here we check if each type has an entry for this event
	checked = ""
	set rstypentry = Server.CreateObject("ADODB.Recordset")
	rstypentry.ActiveConnection = MM_MYCONNECTIONNAME_STRING
	rstypentry.Source = "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "
	rstypentry.CursorType = 0
	rstypentry.CursorLocation = 2
	rstypentry.LockType = 3
	rstypentry.Open()
	rstypentry_numRows = 0

	if (not rstypeentry.EOF) then checked = " checked='checked' "

	rstypeentry.Close()
	set rstypeentry = nothing

With:

		'here we check if each type has an entry for this event
	checked = ""
	set rstypentry = Server.CreateObject("ADODB.Recordset")
	rstypentry.ActiveConnection = MM_MYCONNECTIONNAME_STRING
	rstypentry.Source = "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "
	rstypentry.CursorType = 0
	rstypentry.CursorLocation = 2
	rstypentry.LockType = 3
	rstypentry.Open()
	rstypentry_numRows = 0

	While (NOT rstypentry.EOF)
		checked = " checked='checked' "
		rstypentry.MoveNext()
	Wend
	If (rstypentry.CursorType > 0) Then
		rstypentry.MoveFirst
	Else
		rstypentry.Requery
	End If

	rstypeentry.Close()
	set rstypeentry = nothing

And make sure you don't do a line break where it's broken in this code block (halfway through the source statement).

  • Author

OK, now showing

 

ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/admin/events/edit.asp, line 197

 

where 197 is

 

			rstypentry.MoveFirst

 

Removed the line too. Looks like it passed the previous line that was causing an error

So if you remove

 

If (rstypentry.CursorType > 0) Then
		rstypentry.MoveFirst
	Else
		rstypentry.Requery
	End If

Does it work?

  • Author

it gives

 

Microsoft VBScript runtime  error '800a01a8'

Object required: ''

/admin/events/edit.asp, line 196

 

where 196 is

 

		rstypeentry.Close()

 

Odd one, I don't think it is far away though.

  • Author
Does the event you're editing have any type entries?

 

Yes I checked 2 of them when adding to the database (cats 2 and 11)

 

eid = 18

 

and in the tbltypeentry table is showing

 

id eid typeid

15 18 2

16 18 11

I think I've figured it out - because it's going through in sequence, it starts by trying to find an entry for typeid 1, and fails (correctly), so we just have to build in a condition to deal with an empty recordset. Give me a bit and I'll post back.

So, replace this:

 

		'here we check if each type has an entry for this event
	checked = ""
	set rstypentry = Server.CreateObject("ADODB.Recordset")
	rstypentry.ActiveConnection = MM_MYCONNECTIONNAME_STRING
	rstypentry.Source = "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "
	rstypentry.CursorType = 0
	rstypentry.CursorLocation = 2
	rstypentry.LockType = 3
	rstypentry.Open()
	rstypentry_numRows = 0

	While (NOT rstypentry.EOF)
		checked = " checked='checked' "
		rstypentry.MoveNext()
	Wend

	rstypeentry.Close()
	set rstypeentry = nothing

With this:

 

		'here we check if each type has an entry for this event
	checked = ""
	set rstypentry = Server.CreateObject("ADODB.Recordset")
	rstypentry.ActiveConnection = MM_MYCONNECTIONNAME_STRING
	rstypentry.Source = "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "
	rstypentry.CursorType = 0
	rstypentry.CursorLocation = 2
	rstypentry.LockType = 3
	rstypentry.Open()
	rstypentry_numRows = 0
	if not(rstypeentry.BOF and rstypeentry.EOF) then		
		While (NOT rstypentry.EOF)
			checked = " checked='checked' "
			rstypentry.MoveNext()
		Wend

		rstypeentry.Close()
	endif
	set rstypeentry = nothing

  • Author

Once pasted in and uploaded I got this:

 

Microsoft VBScript compilation  error '800a0400'

Expected statement

/admin/events/edit.asp, line 199

endif
^

 

so thought the endif might need to be end if?

 

Tried that and now giving:

 

Microsoft VBScript runtime  error '800a01a8'

Object required: ''

/admin/events/edit.asp, line 192

 

192 =

		 if not(rstypeentry.BOF and rstypeentry.EOF) then

  • Author

so the whole of that section now reads in full

 

<%
dim checked, rstypeentry, rstypeentry_numRows
While (NOT rstype.EOF)

	'here we check if each type has an entry for this event
	checked = ""
	set rstypentry = Server.CreateObject("ADODB.Recordset")
	rstypentry.ActiveConnection = MM_MYCONNECTIONNAME_STRING
	rstypentry.Source = "SELECT id FROM tbltypeentry WHERE (eid=" & rsedit.Fields.Item("eid").Value & ") AND (typeid=" & rstype.Fields.Item("typeid").Value & ") "
	rstypentry.CursorType = 0
	rstypentry.CursorLocation = 2
	rstypentry.LockType = 3
	rstypentry.Open()
	rstypentry_numRows = 0
	if not(rstypeentry.BOF and rstypeentry.EOF) then		
		While (NOT rstypentry.EOF)
			checked = " checked='checked' "
			rstypentry.MoveNext()
		Wend

		rstypeentry.Close()
	endif
	set rstypeentry = nothing
	%>
	<div>
	<input type="checkbox" name="typeid" value="<%=rstype.Fields.Item("typeid").Value%>" <%=checked%> /> <%=rstype.Fields.Item("typename").Value%>
	</div>
	<%
 rstype.MoveNext()
Wend
%>

 

Will try and tinker with it. Really appreciate your help

end if not endif

 

Guess it's been a while since I was working in ASP!

 

You must be as tired as me - figured you'd spot that... :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.