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

 

A Submission Problem

 
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 >> A Submission Problem
Page: [1]
 
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>
BeTheBall

 

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

 
RE: A Submission Problem - 3/10/2006 0:01:21   
I would be half-tempted to switch to using a SQL insert statement as opposed to the addNew method used when you go with the Send to Database option. With an INSERT statement you are more likely to at the least get an error if the insert fails.

_____________________________

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 dschmuecker)
dschmuecker

 

Posts: 158
Joined: 10/27/2003
Status: offline

 
RE: A Submission Problem - 3/11/2006 1:11:08   
Thanks. I will give that a try. I could use the experience on not depending on Frontpage generated code.

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: A Submission Problem - 3/11/2006 10:04:10   
You can still use the DRW if you want. What you would do is copy your submission form to a new page. Then right click the form and instead of choosing "Send to Database", choose "Send to Other". In the action type the name of a page that will contain your Insert SQL, say insert.asp. Then create insert.asp by inserting a DRW, but in step 2 of the DRW choose custom query and there insert the INSERT query. Once you have that working, you can work on adding your email script.

_____________________________

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 dschmuecker)
dschmuecker

 

Posts: 158
Joined: 10/27/2003
Status: offline

 
RE: A Submission Problem - 3/12/2006 22:46:33   
Thanks. I've never used the DRW that way before.

(in reply to dschmuecker)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> A Submission Problem
Page: [1]
Jump to: 1





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