dschmuecker
Posts: 158 Joined: 10/27/2003 Status: offline
|
A Submission Problem - 3/9/2006 23:45:29
The code below is a submission form I created for my school to speed up the processing of increasing cap sizes on classes. The problem I am having is that it doesn't submit all of the time to the (access) database but sends the email out everytime (at least the administrator is getting the email) I've created many asp forms for the staff at my school and have never had a problem like this. I would guess that it submits about half the time to the database. The Update and delete work fine. Could anyone point me in the right direction to look for the problem. Thanks
<%
On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear
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("master_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"
fp_rs.Open "cap", 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(9)
Dim arFormDBFields0(9)
Dim arFormValues0(9)
arFormFields0(0) = "period"
arFormDBFields0(0) = "period"
arFormValues0(0) = Request("period")
arFormFields0(1) = "student"
arFormDBFields0(1) = "student"
arFormValues0(1) = Request("student")
arFormFields0(2) = "notified"
arFormDBFields0(2) = "notified"
arFormValues0(2) = Request("notified")
arFormFields0(3) = "course"
arFormDBFields0(3) = "course"
arFormValues0(3) = Request("course")
arFormFields0(4) = "department"
arFormDBFields0(4) = "department"
arFormValues0(4) = Request("department")
arFormFields0(5) = "term"
arFormDBFields0(5) = "term"
arFormValues0(5) = Request("term")
arFormFields0(5) = "term"
arFormDBFields0(5) = "term"
arFormValues0(6) = Request("comments")
arFormFields0(6) = "comments"
arFormDBFields0(6) = "comments"
arFormValues0(7) = Request("counselor")
arFormFields0(7) = "counselor"
arFormDBFields0(7) = "counselor"
arFormValues0(8) = Request("homework")
arFormFields0(8) = "homework"
arFormDBFields0(8) = "homework"
FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"
fp_rs.Close
fp_conn.Close
' Declare a variable to contain your mail message
Dim myMail
' Create a new instance of the New Mail Object
Set myMail = CreateObject("CDO.message")
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<title>Cap Size</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""FFFFFF"">"
HTML = HTML & "<p><font size =""3"" face=""Arial"">"
Html = Html & "<b>Cap Size Form</b><br><br>"
Html = Html & "STUDENT: " & "<u>" & request.form("student") & "</u>" & " "
Html = Html & "COUNSELOR: " & "<u>" & request.form("counselor") & "</u>" & "<br><br>"
Html = Html & "TEACHER: " & "<u>" & request.form("homework") & "</u>" & "<br><br>"
Html = Html & "DEPARTMENT: " & "<u>" & request.form("department") & "</u>" & "<br><br>"
Html = Html & "TERM: " & "<u>" & request.form("term") & "</u>" & "<br><br>"
Html = Html & "PERIOD: " & "<u>" & request.form("period") & "</u>" & "<br><br>"
Html = Html & "COURSE: " & "<u>" & request.form("course") & "</u>" & "<br><br>"
Html = Html & "TEACHER: " & "<u>" & request.form("homework") & "</u>" & "<br><br>"
Html = Html & "NOTIFIED: " & "<u>" & request.form("notified") & "</u>" & "<br><br><br><br>"
HTML = HTML & "<A HREF=""http://www.kenn.cr.k12.ia.us/FormsRestricted/classsize/results.asp"">Click here to see results.<A/><BR><BR>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
email = email & request.form("mail")
' Send the message
' This section sends the email and if necessary, reads variables
' from the email form and assigns them to the variables
' that were declared above
' The format is VariableName=request.form("FormFieldName")
MyMail.From= "CAP-SIZE"
MyMail.To="dschmuecker@cr.k12.ia.us;hmaxey@cr.k12.ia.us"
myMail.Subject="Cap Size Submission"
myMail.htmlBody= html
myMail.Importance="2"
myMail.Send
' Be sure to set the New Mail Object to Nothing once you've
' sent your message in order to release memory
Set myMail = Nothing
FP_FormConfirmation "text/html; charset=windows-1252",_
"Form Confirmation",_
"Thank you for submitting the following information:",_
"forma.asp",_
"Return to the form."
End If
End If
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Form</title>
</head>
<body bgcolor="#000000">
<form method="POST" action="formb.asp" webbot-action="--WEBBOT-SELF--">
<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../../_fpclass/fpdbform.inc"-->
<!--#include file="../../_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT * FROM Results where department='::department::' order by course ASC"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="master"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="course"
fp_sMenuValue="course"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<div align="center">
<center>
<table border="1" width="500" bgcolor="#F2F2F2">
<tr>
<td width="100%" align="center" bgcolor="#000000">
<table border="0" width="100%">
<tr>
<td width="26%"></td>
<td width="58%"><b><font color="#FFFFFF" face="Arial">Cap
Increase Request Form</font></b></td>
<td width="16%"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%"><font face="Arial">Student: <input type="text" name="student" size="38"></font></td>
</tr>
<tr>
<td width="100%"><font face="Arial">Counselor: <select size="1" name="counselor">
<option>Muench</option>
<option>Clore</option>
<option>Cronbaugh</option>
<option>Jacobsen</option>
<option>Snook</option>
</select></font></td>
</tr>
<tr>
<td width="100%"><font face="Arial">Department: <input type="text" name="department" value="<%=request("department")%>" size="36"></font></td>
</tr>
<tr>
<td width="100%"><nobr><font face="Arial">Course: <select NAME="course" SIZE="1">
<!--#include file="../../_fpclass/fpdbrgn1.inc"--> <option><%=FP_FieldHTML(fp_rs,"course")%></option>
<!--#include file="../../_fpclass/fpdbrgn2.inc"-->
</select></font></nobr></td>
</tr>
<tr>
<td width="100%"> <!--#include file="../../_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT * FROM staff where homework is not null order by homework Asc"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="staff2"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="homework"
fp_sMenuValue="homework"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<font face="Arial">Teacher:</font>
<select NAME="homework" SIZE="1">
<option>Choose Teacher</option>
<!--#include file="../../_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"homework")%></option>
<!--#include file="../../_fpclass/fpdbrgn2.inc"--></select></td>
</tr>
<tr>
<td width="100%"><font face="Arial">Term:<select size="1" name="term">
<option>Fall</option>
<option>Winter</option>
<option>Spring</option>
</select> Period:<select size="1" name="period">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select> Notified: <input type="checkbox" name="notified" value="YES"></font></td>
</tr>
<tr>
<td width="100%" valign="middle"><font face="Arial">Comments:<br>
<textarea rows="5" name="comments" cols="48"></textarea></font></td>
</tr>
<tr>
<td width="100%"><font face="Arial"><input type="submit" value="Submit" name="B1">
</font></td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
|