|
| |
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
CDO & Option Explicit error - 7/25/2006 10:55:58
Hi I can get the form to work fine if I just want to send to an email using CDO but when I connect it to a database as well I get Microsoft VBScript compilation error '800a0400' Expected statement Software2.asp, line 74 Option Explicit ^ So I've looked around and also tried <%@ Language="VBScript" %> <% Option Explicit %> <% 'rest of script then it comes up with the following although it is on the first line Active Server Pages error 'ASP 0140' Page Command Out Of Order Software2.asp, line 74 The @ command must be the first command within the Active Server Page. I remove the Option Explicit and the form works fine to a database so I don't think the problem is there. Any help would be great Cheers Shona
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 7/26/2006 4:03:19
Hi Spooky Thanks for coming back to me although it says at line 74 it isn't. As you will see from all of this script. If I remove the Option Explicit then the mail isn't sent. There is no include file. I would be interested to hear if anyone else has managed to get cdo to work to email and a database as I really can't see why it isn't working when they both work independently. <% Option Explicit %> <% 'Declare variables Dim sTextBody Dim sName Dim sDepartment Dim sCC Dim sAdd Dim sRemove Dim sFrontpage Dim sAcrobatWriter Dim sComNumber sTextBody = sTextBody & "Name: " & Request("sName") & VbCrLf sTextBody = sTextBody & "Department: " & Request("sDepartment") & VbCrLf sTextBody = sTextBody & "CostCentre: " & Request("sCC") & VbCrLf sTextBody = sTextBody & "Add: " & Request("sAdd") & VbCrLf sTextBody = sTextBody & "Remove: " & Request("sRemove") & VbCrLf sTextBody = sTextBody & "Frontpage: " & Request("sFrontpage") & VbCrLf sTextBody = sTextBody & "Acrobat Writer: " & Request("sAcrobatWriter") & VbCrLf sTextBody = sTextBody & "Computer Number: " & Request("sComNumber") & VbCrLf 'Only run this if it's not the first time If Request.Form("Submit") <> "" Then Dim objMail 'Create the mail object Set objMail = Server.CreateObject("CDO.Message") 'Set key properties objMail.From = "email@oal.com" objMail.To = "email@aol.com" objMail.Subject = "Software Required" objMail.TextBody = sTextBody objMail.Send 'Clean-up Set objMail = Nothing End If %> <% ' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit. On Error Resume Next strErrorUrl = "" If Request.ServerVariables("REQUEST_METHOD") = "POST" Then If Request.Form("VTI-GROUP") = "0" Then Err.Clear Set fp_conn = Server.CreateObject("ADODB.Connection") FP_DumpError strErrorUrl, "Cannot create connection" Set fp_rs = Server.CreateObject("ADODB.Recordset") FP_DumpError strErrorUrl, "Cannot create record set" fp_conn.Open Application("Software4_ConnectionString") FP_DumpError strErrorUrl, "Cannot open database" fp_rs.Open "Results", 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(8) Dim arFormDBFields0(8) Dim arFormValues0(8) arFormFields0(0) = "sAcrobatWriter" arFormDBFields0(0) = "sAcrobatWriter" arFormValues0(0) = Request("sAcrobatWriter") arFormFields0(1) = "sFrontPage" arFormDBFields0(1) = "sFrontPage" arFormValues0(1) = Request("sFrontPage") arFormFields0(2) = "sDepartment" arFormDBFields0(2) = "sDepartment" arFormValues0(2) = Request("sDepartment") arFormFields0(3) = "sAdd" arFormDBFields0(3) = "sAdd" arFormValues0(3) = Request("sAdd") arFormFields0(4) = "sName" arFormDBFields0(4) = "sName" arFormValues0(4) = Request("sName") arFormFields0(5) = "sComNumber" arFormDBFields0(5) = "sComNumber" arFormValues0(5) = Request("sComNumber") arFormFields0(6) = "sCC" arFormDBFields0(6) = "sCC" arFormValues0(6) = Request("sCC") arFormFields0(7) = "sRemove" arFormDBFields0(7) = "sRemove" arFormValues0(7) = Request("sRemove") FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0 fp_rs.Update FP_DumpError strErrorUrl, "Cannot update the database" fp_rs.Close fp_conn.Close FP_FormConfirmation "text/html; charset=windows-1252",_ "Form Confirmation",_ "Thank you for submitting the following information:",_ "Softwarevar2.asp",_ "Return to the form." End If End If %> <html> <head><title>SendMail</title> <meta name="Microsoft Border" content="t"> </head> <body> <form action="--WEBBOT-SELF--" method="POST" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1"> <!--webbot bot="SaveDatabase" SuggestedExt="asp" S-DataConnection="Software4" S-RecordSource="Results" U-Database-URL="../../../fpdb/Software4.mdb" S-Form-Fields="sAcrobatWriter sFrontPage sDepartment sAdd sName sComNumber sCC sRemove" S-Form-DBFields="sAcrobatWriter sFrontPage sDepartment sAdd sName sComNumber sCC sRemove" startspan U-ASP-Include-Url="../../../_fpclass/fpdbform.inc" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../../../_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan i-checksum="52631" --> <p align="center"><b><font size="6" face="Arial">Software Requirements Form</font></b><p> </p> <table CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="530" id="table1"> <tr> <td WIDTH="180" valign="top"><font face="Arial">Name</font></td> <td WIDTH="350" colspan="3"> <input type="text" name="sName" size="20"></td> </tr> <tr> <td WIDTH="180" valign="top"> </td> <td WIDTH="80"> </td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top">Department</td> <td WIDTH="350" colspan="3"> <!--webbot bot="Validation" s-display-name="Dept" b-value-required="TRUE" b-disallow-first-item="TRUE" --><select size="1" name="sDepartment"> <option>Please choose a department</option> <option value="CI - I.T.">CI - I.T</option> <option value="TTGB/ASA - Customer Services">TTGB/ASA - Customer Services </option> <option value="TTGB/CIP - Continuous Improvement Process">TTGB/CIP - Continuous Improvement Process </option> <option value="TTGB/CTG - Finance & Controlling">TTGB/CTG - Finance & Controlling </option> <option value="TTGB/EHK - Research & Development">TTGB/EHK - Research & Development </option> <option value="TTGB/EQM - Product Reliability">TTGB/EQM - Product Reliability </option> <option value="TTGB/IDV - Support Services">TTGB/IDV - Support Services </option> <option value="TTGB/LOG - Logistics">TTGB/LOG - Logistics</option> <option value="TTGB/MKT - Marketing">TTGB/MKT - Marketing </option> <option value="TTGB/PAY - Payroll">TTGB/PAY - Payroll </option> <option value="TTGB/PER - Human Resources">TTGB/PER - Human Resources </option> <option value="TTGB/PJM - Project Management">TTGB/PJM - Project Management </option> <option value="TTGB/PRT - Product Training">TTGB/PRT - Product Training </option> <option value="TTGB/PUR - Purchasing">TTGB/PUR - Purchasing </option> <option value="TTGB/QMM - Quality">TTGB/QMM - Quality </option> <option value="WoP/MFE - Production Engineering">WoP/MFE - Production Engineering </option> <option value="WoP/MFO - Production">WoP/MFO - Production </option> <option value="WoP/OHS - Health & Safety">WoP/OHS - Health & Safety </option> <option value="WoP/TEF - Technical Engineering Functions">WoP/TEF - Technical Engineering Functions </option> </select></td> </tr> <tr> <td WIDTH="180" valign="top"> </td> <td WIDTH="80"> </td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top">Cost Centre</td> <td WIDTH="350" colspan="3"> <select name="sCC" size="1"> <option>Cost Centre Codes</option> <option value="557810">557810</option> <option value="557420">557420</option> <option value="557511">557511</option> <option value="557512">557512</option> <option value="557231">557720</option> <option value="557720">557231</option> <option value="557410">557410</option> <option value="557521">557521</option> <option value="557729">557720</option> <option value="557281">557281</option> <option value="557630">557630</option> <option value="557410">557410</option> <option value="557260">557260</option> <option value="557510">557510</option> <option value="557620">557620</option> <option value="557130">557130</option> <option value="557520">557520</option> <option value="557517">557517</option> <option value="557230">557230</option> <option value="557250">557250</option> <option value="557231">557231</option> <option value="557232">557232</option> </select></td> </tr> <tr> <td WIDTH="180" valign="top"> </td> <td WIDTH="80"> </td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top"><font face="Arial">Add</font></td> <td WIDTH="80"><input type="checkbox" name="sAdd" value="Yes Add"></td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top">Remove</td> <td WIDTH="80"><input type="checkbox" name="sRemove" value="Yes Remove"></td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top"> </td> <td WIDTH="170" colspan="3"> </td> </tr> <tr> <td WIDTH="180" valign="top"><font face="Arial">Computer Number</font></td> <td WIDTH="170" colspan="3"><input type="text" name="sComNumber" size="20"></td> </tr> <tr> <td WIDTH="180" valign="top"> </td> <td WIDTH="80"> </td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top"><font face="Arial">Acrobat Writer</font></td> <td WIDTH="80"> <input type="checkbox" name="sAcrobatWriter" value="AcrobatWriter"></td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top"><font face="Arial">Frontpage</font></td> <td WIDTH="80"><input type="checkbox" name="sFrontPage" value="Frontpage"></td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> <tr> <td WIDTH="180" valign="top"> </td> <td WIDTH="80"><input type="submit" name="Submit" value="Submit"></td> <td WIDTH="10"> </td> <td WIDTH="80"> </td> </tr> </table> <hr> </form> </body> </html> Hope you can help Cheers Shona
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 7/26/2006 5:42:34
quote:
ORIGINAL: Spooky How are you joining the 2 scripts? Are you showing me 2 pages of working code, or one page of non working code? Hi that was one page of non working code. Although I think I've solved my problem but sure would appreciate your confirmation because it all seems too simple! I've managed to get CDONTs to work fine in the past and then just a shot in the dark I decided to change the line Set objCDOMail = Server.CreateObject("CDONTS.NewMail") to Set objCDOMail = Server.CreateObject("CDO.Message") and hey presto it all works and I've spent a whole week trying to write it all from scratch ! Please confirm that this is correct? Cheers Shona
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 7/27/2006 9:51:46
Oops still not working forgot I had it going to a confirmation page which had CDONTS on it. Still need some help Cheers Shona
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 8/1/2006 11:49:32
quote:
Microsoft VBScript compilation error '800a0400' Expected statement Software2.asp, line 74 Option Explicit ^ I've done away with the confirmation page for now so it's all on one page
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 8/1/2006 12:51:50
Hi Further to my message above I think I'm nearly there and have now changed some of the scripting. I now get the information to go to the database and the mail arrives with the field names but not the information that was typed into the fields ! Do hope you can help? <!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%
Dim sTextBody
Dim sName
Set cdoConfig = CreateObject("CDO.Configuration")
sTextBody = sTextBody & "Name: " & Request("sName") & VbCrLf
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.server.name"
.Update
End With
Dim objMail
'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")
'Set key properties
objMail.From = email@aol.com
objMail.To = "email@aol.com"
objMail.Subject = "Software Required"
objMail.TextBody = sTextBody
objMail.Send
' End If
Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>
<%
' FP_ASP ASP Automatically generated by a FrontPage Component. Do not Edit.
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("Name_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"
fp_rs.Open "Results", 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(8)
Dim arFormDBFields0(8)
Dim arFormValues0(8)
arFormFields0(4) = "sName"
arFormDBFields0(4) = "sName"
arFormValues0(4) = Request("sName")
FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"
fp_rs.Close
fp_conn.Close
FP_FormConfirmation "text/html; charset=windows-1252",_
"Form Confirmation",_
"Thank you for submitting the following information:",_
"sendmail1.asp",_
"Return to the form."
End If
End If
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
%>
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 8/2/2006 3:08:00
Thanks for getting back to me The same thing information inserted into database and mail received but only the field name. Cheers Shona
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 8/2/2006 5:10:51
Cheers No the value isn't coming through the only thing that comes through is this Name: Shona
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 8/2/2006 5:40:40
Sorry that must have looked like Shona came through it didn't just Name:
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 8/2/2006 7:22:48
Hi Now the field to fill in or the submit button don't appear just this text = Name
|
|
|
|
Shona Smith
Posts: 24 Joined: 4/19/2005 Status: offline
|
RE: CDO & Option Explicit error - 8/3/2006 4:27:15
Thank you for getting back to me. Unfortunately now I don't receive the mail. Cheers Shona
|
|
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
|
|
|