Can somebody check this ASP code? (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


spcafc -> Can somebody check this ASP code? (5/17/2004 17:29:50)

I keep getting this error:

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/groupinfo.asp, line 31

Here's the code:
----------------------------------------

<%
Function ParseBody (strText)

strText = Replace (strText, Chr (13), "<br>")
ParseBody - strText

End Function

Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("groupinfo_ConnectionString")

Set myConnection = Server.CreateObject("ADODB.Connection")

myConnection.Open myConnString

mySQL= "INSERT INTO FormResults"
mySQL= mySQL & "(_Phone,_URL,_City,Physical Information_Address2,_Name,Mailing Information_Address2,_County,Physical_Information_City,Mailing_Information_FAX,MailingInformation_Email,Physical Information_StreetAddress,Physical Information_ZipCode,Government Run Facilities_Title,Government Run Facilities_Organization,_ZipCode,_StreetAddress1) "
mySQL= mySQL & "VALUES ('" & Request.Form("_Phone") & "','"
mySQL= mySQL & Request.Form("_URL")
mySQL= mySQL & Request.Form("_City")
mySQL= mySQL & Request.Form("Physical Information_Address2")
mySQL= mySQL & Request.Form("_Name")
mySQL= mySQL & Request.Form("Mailing Information_Address2")
mySQL= mySQL & Request.Form("_County")
mySQL= mySQL & Request.Form("Physical Information_City")
mySQL= mySQL & Request.Form("Mailing_Information_FAX")
mySQL= mySQL & Request.Form("MailingInformation_Email")
mySQL= mySQL & Request.Form("Physical Information_StreetAddress")
mySQL= mySQL & Request.Form("Physical Information_ZipCode")
mySQL= mySQL & Request.Form("Government Run Facilities_Title")
mySQL= mySQL & Request.Form("Government Run Facilities_Organization")
mySQL= mySQL & Request.Form("_ZipCode")
mySQL= mySQL & Request.Form("_StreetAddress1")

myConnection.Execute mySQL

myConnection.Close

Set myConnection = Nothing

Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
DimstrBody

strFrom="spcafc@mindspring.com"

strTo=Request.Form("MailingInformation_Email")

strSubject = "Thank You! NC Animal Welfare Directory Submission"

strBody="Thank you for sending your information - it will be added to/updated in our database." & Chr(13)
strBody = strBody & "Please remember the following:" & Chr(13)
strBody = strBody & "If you are a 501(c)3 organization please send a copy of the FIRST page of your IRS certification letter" & Chr(13)
strBody = strBody & "OR" & Chr(13)
strBody = strBody & "if NOT a 501(c)3 than a letter from your main vet on their letterhead." & Chr(13)
strBody = strBody & "Send the info to:" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "105 MILL CREEK DRIVE" & Chr(13)
strBody = strBody & "YOUNGSVILLE NC 27596" & Chr(13)
strBody = strBody & "OR"
strBody = strBody & "you may send it as an attachment to:" & Chr(13)
strBody = strBody & "spcafc@mindspring.com" & Chr(13)
strBody = strBody & "Thank you again for helping NC's animals!" & Chr(13)
strBody = strBody & "Rebecca Rodgers" & Chr(13)
strBody = strBody & "President" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "North Carolina"

myCDONTSMail.Send strFrom,strSubject,StrBody

Set myCDONTSMail = Nothing

%>




DesiMcK -> RE: Can somebody check this ASP code? (5/17/2004 17:38:25)

Underneath your SQL statement insert
response.write mySQL


This will show you the mySQL statement: At present it looks like
quote:

INSERT INTO FormResults(_Phone,_URL,_City,Physical Information_Address2,_Name,Mailing Information_Address2,_County,Physical_Information_City,Mailing_Information_FAX,MailingInformation_Email,Physical Information_StreetAddress,Physical Information_ZipCode,Government Run Facilities_Title,Government Run Facilities_Organization,_ZipCode,_StreetAddress1) VALUES ('','


It would seem that the request.form values are not being read ffrom your form.

Desi




Spooky -> RE: Can somebody check this ASP code? (5/18/2004 3:36:17)

Place brackets around all of your column names []
Starting with an underscore isnt a good idea




spcafc -> RE: Can somebody check this ASP code? (5/18/2004 8:46:52)

quote:

ORIGINAL: Spooky

Place brackets around all of your column names []
Starting with an underscore isn't a good idea


Tried that. Removed the underscores too. Now I get this when I test it:

Microsoft JET Database Engine error '80040e14'

Syntax error in string in query expression ''xYOUNGSVILLEMILL CREEK DRIVERebeccaMILL CREEK DRIVEfranklinxSPCAFC@MINDSPRING.COMMILL CREEK DRIVE00000-9626xx00000-9626MILL CREEK DRIVE'.

/groupinfo.asp, line 35




BeTheBall -> RE: Can somebody check this ASP code? (5/18/2004 12:27:16)

There needs to be a comma following each value (except the last one inserted). Something like:

mySQL= mySQL & "VALUES ('" & Request.Form("_Phone") & "',"
mySQL= mySQL & "'"&Request.Form("_URL")&"',"
mySQL= mySQL & "'"&Request.Form("_City")&"',"
mySQL= mySQL & "'"&Request.Form("Physical Information_Address2")&"',"
mySQL= mySQL & "'"&Request.Form("_Name")&"',"
mySQL= mySQL & "'"&Request.Form("Mailing Information_Address2")&"',"
mySQL= mySQL & "'"&Request.Form("_County")&"',"
mySQL= mySQL & "'"&Request.Form("Physical Information_City")&"',"
mySQL= mySQL & "'"&Request.Form("Mailing_Information_FAX")&"',"
mySQL= mySQL & "'"&Request.Form("MailingInformation_Email")&"',"
mySQL= mySQL & "'"&Request.Form("Physical Information_StreetAddress")&"',"
mySQL= mySQL & "'"&Request.Form("Physical Information_ZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("Government Run Facilities_Title")&"',"
mySQL= mySQL & "'"&Request.Form("Government Run Facilities_Organization")&"',"
mySQL= mySQL & "'"&Request.Form("_ZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("_StreetAddress1")&"'"

Then, in this section:

mySQL= mySQL & "(_Phone,_URL,_City,Physical Information_Address2,_Name,Mailing Information_Address2,_County,Physical_Information_City,Mailing_Information_FAX,MailingInformation_Email,Physical Information_StreetAddress,Physical Information_ZipCode,Government Run Facilities_Title,Government Run Facilities_Organization,_ZipCode,_StreetAddress1) "

Make sure any field names that have spaces are surrounded by []. Database field names should not use spaces, but if they do, you must put them in brackets. For example,

Government Run Facilities_Title

Would need to be:

[Government Run Facilities_Title]

Good luck.




spcafc -> RE: Can somebody check this ASP code? (5/19/2004 12:07:26)

Ok I keep getting an error. This is the new code with the suggested corrections. So why am I getting an error?

<%
Function ParseBody (strText)
strText = Replace (strText, Chr (13), "<br>")
ParseBody - strText
End Function

Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("groupinfo_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString

mySQL= "INSERT INTO FormResults"
mySQL= mySQL & "(Phone,Website,City,PhysicalAddress2,Name,MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) "
mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "','"
mySQL= mySQL & "'"&Request.Form("Website")&"','"
mySQL= mySQL & "'"&Request.Form("City")&"','"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress2")&"','"
mySQL= mySQL & "'"&Request.Form("Name")&"','"
mySQL= mySQL & "'"&Request.Form("MailingAddress2")&"','"
mySQL= mySQL & "'"&Request.Form("County")&"','"
mySQL= mySQL & "'"&Request.Form("PhysicalCity")&"','"
mySQL= mySQL & "'"&Request.Form("Fax")&"','"
mySQL= mySQL & "'"&Request.Form("Email")&"','"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress")&"','"
mySQL= mySQL & "'"&Request.Form("PhysicalZipCode")&"','"
mySQL= mySQL & "'"&Request.Form("GovtDept")&"','"
mySQL= mySQL & "'"&Request.Form("GovtHead")&"','"
mySQL= mySQL & "'"&Request.Form("ZipCode")&"','"
mySQL= mySQL & "'"&Request.Form("MailingAddress")&""


myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing

Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
DimstrBody

strFrom="spcafc@mindspring.com"
strTo=Request.Form("MailingInformation_Email")

strSubject = "Thank You! NC Animal Welfare Directory Submission"
strBody="Thank you for sending your information - it will be added to/updated in our database." & Chr(13)
strBody = strBody & "Please remember the following:" & Chr(13)
strBody = strBody & "If you are a 501(c)3 organization please send a copy of the FIRST page of your IRS certification letter" & Chr(13)
strBody = strBody & "OR" & Chr(13)
strBody = strBody & "if NOT a 501(c)3 than a letter from your main vet on their letterhead." & Chr(13)
strBody = strBody & "Send the info to:" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "105 MILL CREEK DRIVE" & Chr(13)
strBody = strBody & "YOUNGSVILLE NC 27596" & Chr(13)
strBody = strBody & "OR"
strBody = strBody & "you may send it as an attachment to:" & Chr(13)
strBody = strBody & "spcafc@mindspring.com" & Chr(13)
strBody = strBody & "Thank you again for helping NC's animals!" & Chr(13)
strBody = strBody & "Rebecca Rodgers" & Chr(13)
strBody = strBody & "President" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "North Carolina"

myCDONTSMail.Send strFrom,strSubject,StrBody
Set myCDONTSMail = Nothing

%>




BeTheBall -> RE: Can somebody check this ASP code? (5/19/2004 12:16:02)

There should not be a single quote after the commas and you missed a single quote at: mySQL= mySQL & "'"&Request.Form("MailingAddress")&"". That section should look like this:

mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "',"
mySQL= mySQL & "'"&Request.Form("Website")&"',"
mySQL= mySQL & "'"&Request.Form("City")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("Name")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("County")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalCity")&"',"
mySQL= mySQL & "'"&Request.Form("Fax")&"',"
mySQL= mySQL & "'"&Request.Form("Email")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("GovtDept")&"',"
mySQL= mySQL & "'"&Request.Form("GovtHead")&"',"
mySQL= mySQL & "'"&Request.Form("ZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress")&"'"

Also, I think "Name" is a reserved word so change:

mySQL= mySQL & "(Phone,Website,City,PhysicalAddress2,Name,MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) "

to:

mySQL= mySQL & "(Phone,Website,City,PhysicalAddress2,[Name],MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) "

If that still throws an error, post the actual error message.

Good luck.




spcafc -> RE: Can somebody check this ASP code? (5/19/2004 12:53:37)

ok here's the error:

Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression '''WEBSITE','CITY','PHYSICALADDRESS2','NAME','MAILINGADDRESS2','COUNTY','','0FAX','EMAIL','PHYSICALADDRESS','0PHYSZIPCODE','GOVTDEPT','GOVTHEAD','0ZIPCODE','MAILINGADDRESS'.

/groupinfo.asp, line 35


Now here is the line of code that goes with it (I noticed some values aren't being captured: Phone and Physical City)

mySQL= mySQL & "(Phone,Website,City,PhysicalAddress2,[Name],MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) "




BeTheBall -> RE: Can somebody check this ASP code? (5/19/2004 13:15:16)

Can you post the code for the form that submits the updated info?




spcafc -> RE: Can somebody check this ASP code? (5/19/2004 14:05:00)

I am assuming the html code? Here it is:

<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>Organization Information</title>

<script language="JavaScript" fptype="dynamicoutline">
<!--
function dynOutline() {}
//-->
</script>
<script language="JavaScript1.2" fptype="dynamicoutline" src="outline.js">
</script>
<script language="JavaScript1.2" fptype="dynamicoutline" for="document" event="onreadystatechange()">
<!--
initOutline()
//-->
</script>














<meta name="Microsoft Theme" content="watermar 011, default">
<meta name="Microsoft Border" content="tlb">
</head>

<body onclick="dynOutline()">

<p style="margin-top: 0; margin-bottom: 0"><font size="2">Please fill in the
following information for your organization, government facility, veterinarian
office or animal related activity for North Carolina ONLY. If you have any
questions you may send them to </font>
<a href="mailto:spcafc@mindspring.com"><font size="2">spcafc@mindspring.com</font></a></p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<font color="#339966" size="2"><b>******QUALIFICATIONS FOR ADDITION TO THE NC
DIRECTORY******</b></font></p>
<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>
<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>
<ul dynamicoutline>
<li>
<p style="margin-top: 0; margin-bottom: 0"><font size="2">I<b>f you are a 501(c)3
registered Organization you must provide the following:</b></font><p style="margin-top: 0; margin-bottom: 0"> <ul>
<li>
<p style="margin-top: 0; margin-bottom: 0"><b><font size="2">Please send a copy
of the <u>FIRST</u> page of your IRS determination letter.</font></b></li>
</ul>
<p style="margin-top: 0; margin-bottom: 0"> </li>
<li>
<p style="margin-top: 0; margin-bottom: 0"><b><font size="2">If you are NOT a
501(c)3 registered Organization OR you are an Independent Rescue you must provide the
following:</font></b><p style="margin-top: 0; margin-bottom: 0"> <ul>
<li>
<p style="margin-top: 0; margin-bottom: 10"><b><font size="2">Copy of your
adoption contract AND a letter of reference confirming that you do animal
rescue from your primary veterinarian on his or her letterhead. Also any
references from registered 501(c)3 organizations will be helpful.</font></b></li>
</ul>
</li>
<li>
<p style="margin-top: 0; margin-bottom: 0"><b><font size="2">If you are a
government run facility please also fill in the Department you are under and
the name of the Head of that department. </font></b></li>
</ul>
<p style="margin-top: 0; margin-bottom: 0" align="center">
<font size="2" color="#FF0000"><b>If you are unable to provide us with the
above info your group will NOT be included in the Directory.</b></font><hr>
<p align="center" style="margin-top: 0; margin-bottom: 0"><b>
<font size="2" color="#339966">***Your Current Information***</font></b></p>
<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>
<p align="center" style="margin-top: 0; margin-bottom: 0"><b>***REQUIRED FIELDS
ARE IN <font color="#FF0000">RED</font>***</b></p>
<form method="POST" action="groupinfo.asp" onSubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1" webbot-onSubmit="return FrontPage_Form1_Validator(this)">
<TABLE>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<em>Organizations FULL Name:</em></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="Organizations FULL Name" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="100" --><INPUT NAME="Name" SIZE=35 maxlength="100"> </TD>
</TR>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<em>County your group is located </em></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="County" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="100" --><INPUT NAME="County" SIZE=35 maxlength="100"> </TD>
</TR>
<TR>
<TD ALIGN="right"> </TD>
<TD> <em style="font-style: normal; font-weight: 700"><font color="#339966" size="2">Mailing
Address</font></em></TD>
</TR>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<EM>Street Address</EM></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="Street Address1" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="100" --><INPUT NAME="MailingAddress" SIZE=35 maxlength="100"> </TD>
</TR>
<TR>
<TD ALIGN="right">
<EM>Address (cont.)</EM></TD>
<TD>
<INPUT NAME="MailingAddress2" SIZE=35> </TD>
</TR>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<EM>City</EM></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="City" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="100" --><INPUT NAME="City" SIZE=35 maxlength="100"> </TD>
</TR>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<EM>Zip Code</EM></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="Zip Code" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="12" --><INPUT NAME="ZipCode" SIZE=12 MAXLENGTH=12> </TD>
</TR>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<EM> Phone</EM></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="Phone" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="25" --><INPUT NAME="Phone" SIZE=25 MAXLENGTH=25> </TD>
</TR>
<TR>
<TD ALIGN="right">
<EM>FAX</EM></TD>
<TD>
<INPUT NAME="Fax" SIZE=25 MAXLENGTH=25> </TD>
</TR>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<EM>E-mail</EM></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="Email" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="100" --><INPUT NAME="Email" SIZE=25 maxlength="100"> </TD>
</TR>
<TR>
<TD ALIGN="right"><font color="#FF0000">
<em>Website (if you have one)</em></font></TD>
<TD>
<!--webbot bot="Validation" s-display-name="Website" b-value-required="TRUE" i-maximum-length="100" --><INPUT NAME="Website" SIZE=25 MAXLENGTH=100> </TD>
</TR>
</TABLE>
<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>
<TABLE width="458">
<TR>
<TD ALIGN="right" width="193"> </TD>
<TD width="255">
<em style="font-style: normal; font-weight: 700"><font size="2" color="#339966">
Physical Address</font></em> <font size="2" color="#339966">(only if you have a
facility)</font></TD>
</TR>
<TR>
<TD ALIGN="right" width="193">
<EM>Street Address</EM></TD>
<TD width="255">
<INPUT NAME="PhysicalAddress" SIZE=35> </TD>
</TR>
<TR>
<TD ALIGN="right" width="193">
<EM>Address (cont.)</EM></TD>
<TD width="255">
<INPUT NAME="PhysicalAddress2" SIZE=35> </TD>
</TR>
<TR>
<TD ALIGN="right" width="193">
<EM>City</EM></TD>
<TD width="255">
<INPUT NAME="PhysicaCity" SIZE=35> </TD>
</TR>
<TR>
<TD ALIGN="right" width="193">
<EM>Zip/Postal Code</EM></TD>
<TD width="255">
<INPUT NAME="PhysicalZipcode" SIZE=12 MAXLENGTH=12> </TD>
</TR>
</TABLE>
<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<b><font size="2" color="#339966">***For Government Run Facilities:***</font></b></p>
<TABLE width="457">
<TR>
<TD ALIGN="right" width="192">
<em>Department</em></TD>
<TD width="255">
<INPUT NAME="GovtDept" SIZE=35> </TD>
</TR>
<TR>
<TD ALIGN="right" width="192">
<em>Department Head</em></TD>
<TD width="255">
<INPUT NAME="GovtHead" SIZE=35> </TD>
</TR>
</TABLE>
<p align="center" style="margin-top: 0; margin-bottom: 0"><b>BEFORE SUBMITTING
YOUR INFO PLEASE MAKE SURE THE EMAIL YOU ENTERED ABOVE IS NOT FULL AS A
CONFIRMATION EMAIL WILL BE SENT TO YOU. THIS EMAIL CONTAINS FURTHER
INSTRUCTIONS!</b></p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<hr></body>

</html>




BeTheBall -> RE: Can somebody check this ASP code? (5/19/2004 14:53:05)

The only other error I see is in your form. You have a field titled "PhysicaCity". It's missing the "l" (PhysicalCity). Other than that, are you ensuring that each form field has a value when you submit? If not, do the db fields that correspond to the blank form fields allow "zero-length"?




spcafc -> RE: Can somebody check this ASP code? (5/19/2004 15:49:35)

Ok went and corrected all the issues with the spelling (duh for me) and check to see if zero length was allowed (most were "no"). But I am still getting a syntax error:

Syntax error (missing operator) in query expression '''WEBSITE','PHYSICALCITY','PHYSICALADDRESS2','NAME','PHYSICALADDRESS2','COUNTY','PHYSICALCITY','0FAX','EMAIL','PHYSICALADDRESS2','0PHYSZIPCODE','GOVTHEAD','GOVTHEAD','0PHYSZIPCODE','PHYSICALADDRESS2'.

/groupinfo.asp, line 35




Spooky -> RE: Can somebody check this ASP code? (5/19/2004 15:58:54)

Could you please write the entire SQL string?

response.write mySQL
response.end

myConnection.Execute mySQL

myConnection.Close




spcafc -> RE: Can somebody check this ASP code? (5/19/2004 16:13:43)

<%
Function ParseBody (strText)
strText = Replace (strText, Chr (13), "<br>")
ParseBody - strText
End Function

Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("groupinfo_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString

mySQL= "INSERT INTO FormResults"
mySQL= mySQL & "([Phone],Website,City,PhysicalAddress2,[Name],MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) "
mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "','"
mySQL= mySQL & "'"&Request.Form("Website")&"',"
mySQL= mySQL & "'"&Request.Form("City")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("Name")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("County")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalCity")&"',"
mySQL= mySQL & "'"&Request.Form("Fax")&"',"
mySQL= mySQL & "'"&Request.Form("Email")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("GovtDept")&"',"
mySQL= mySQL & "'"&Request.Form("GovtHead")&"',"
mySQL= mySQL & "'"&Request.Form("ZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress")&""


myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing

Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
DimstrBody

strFrom="spcafc@mindspring.com"
strTo=Request.Form("MailingInformation_Email")

strSubject = "Thank You! NC Animal Welfare Directory Submission"
strBody="Thank you for sending your information - it will be added to/updated in our database." & Chr(13)
strBody = strBody & "Please remember the following:" & Chr(13)
strBody = strBody & "If you are a 501(c)3 organization please send a copy of the FIRST page of your IRS certification letter" & Chr(13)
strBody = strBody & "OR" & Chr(13)
strBody = strBody & "if NOT a 501(c)3 than a letter from your main vet on their letterhead." & Chr(13)
strBody = strBody & "Send the info to:" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "105 MILL CREEK DRIVE" & Chr(13)
strBody = strBody & "YOUNGSVILLE NC 27596" & Chr(13)
strBody = strBody & "OR"
strBody = strBody & "you may send it as an attachment to:" & Chr(13)
strBody = strBody & "spcafc@mindspring.com" & Chr(13)
strBody = strBody & "Thank you again for helping NC's animals!" & Chr(13)
strBody = strBody & "Rebecca Rodgers" & Chr(13)
strBody = strBody & "President" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "North Carolina"

myCDONTSMail.Send strFrom,strSubject,StrBody
Set myCDONTSMail = Nothing

%>




Spooky -> RE: Can somebody check this ASP code? (5/19/2004 16:16:27)

No, add the code I wrote above

response.write mySQL
response.end

myConnection.Execute mySQL

myConnection.Close


Then open the web page. The SQL string will be written to the page.
Paste it here.




Spooky -> RE: Can somebody check this ASP code? (5/19/2004 16:19:08)

A couple of things :

mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "','"
mySQL= mySQL & "'"&Request.Form("Website")&"',"
mySQL= mySQL & "'"&Request.Form("City")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("Name")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("County")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalCity")&"',"
mySQL= mySQL & "'"&Request.Form("Fax")&"',"
mySQL= mySQL & "'"&Request.Form("Email")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("GovtDept")&"',"
mySQL= mySQL & "'"&Request.Form("GovtHead")&"',"
mySQL= mySQL & "'"&Request.Form("ZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress")&""


Should be :
mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "',"
mySQL= mySQL & "'"&Request.Form("Website")&"',"
mySQL= mySQL & "'"&Request.Form("City")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("Name")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("County")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalCity")&"',"
mySQL= mySQL & "'"&Request.Form("Fax")&"',"
mySQL= mySQL & "'"&Request.Form("Email")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("GovtDept")&"',"
mySQL= mySQL & "'"&Request.Form("GovtHead")&"',"
mySQL= mySQL & "'"&Request.Form("ZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress")&"'"




BeTheBall -> RE: Can somebody check this ASP code? (5/19/2004 18:16:08)

I can't believe Spooky and I both missed this (Actually, it's not too hard to believe I missed it). In the last line of the SQL, you are missing the closing ")"
So, this:

mySQL= mySQL & "'"&Request.Form("MailingAddress")&"'"

should be:

mySQL= mySQL & "'"&Request.Form("MailingAddress")&"')"




Spooky -> RE: Can somebody check this ASP code? (5/19/2004 18:28:09)

Lol, thats why write is good [:D]
I did get the quote though[;)]




spcafc -> RE: Can somebody check this ASP code? (5/20/2004 6:48:28)

fixed the missing bits. added the code you requested. here is the result:

INSERT INTO FormResults([Phone],Website,City,PhysicalAddress2,[Name],MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) VALUES ('0PHONE',''WEBSITE','CITY','PHYSICALADDRESS2','NAME','MAILINGADDRESS2','COUNTY','PHYSICALCITY','0FAX','EMAIL','PHYSICALADDRESS','0PHYSZIPCODE','GOVTDEPT','GOVTHEAD','ZIPCODE','MAILINGADDRESS')




BeTheBall -> RE: Can somebody check this ASP code? (5/20/2004 9:34:19)

Are you sure you got rid of the single quote after the comma in this line?

mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "','"

It should be:

mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "',"




spcafc -> RE: Can somebody check this ASP code? (5/20/2004 12:16:32)

double checked that quote mark and it WAS there so I removed it. Here is the code as it stands now:

<%
Function ParseBody (strText)
strText = Replace (strText, Chr (13), "<br>")
ParseBody - strText
End Function

Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("groupinfo_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString

mySQL= "INSERT INTO FormResults"
mySQL= mySQL & "([Phone],Website,City,PhysicalAddress2,[Name],MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) "
mySQL= mySQL & "VALUES ('" & Request.Form("Phone") & "',"
mySQL= mySQL & "'"&Request.Form("Website")&"',"
mySQL= mySQL & "'"&Request.Form("City")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("Name")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress2")&"',"
mySQL= mySQL & "'"&Request.Form("County")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalCity")&"',"
mySQL= mySQL & "'"&Request.Form("Fax")&"',"
mySQL= mySQL & "'"&Request.Form("Email")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalAddress")&"',"
mySQL= mySQL & "'"&Request.Form("PhysicalZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("GovtDept")&"',"
mySQL= mySQL & "'"&Request.Form("GovtHead")&"',"
mySQL= mySQL & "'"&Request.Form("ZipCode")&"',"
mySQL= mySQL & "'"&Request.Form("MailingAddress")&"')"

response.write mySQL
response.end
myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing

Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
DimstrBody

strFrom="spcafc@mindspring.com"
strTo=Request.Form("MailingInformation_Email")

strSubject = "Thank You! NC Animal Welfare Directory Submission"
strBody="Thank you for sending your information - it will be added to/updated in our database." & Chr(13)
strBody = strBody & "Please remember the following:" & Chr(13)
strBody = strBody & "If you are a 501(c)3 organization please send a copy of the FIRST page of your IRS certification letter" & Chr(13)
strBody = strBody & "OR" & Chr(13)
strBody = strBody & "if NOT a 501(c)3 than a letter from your main vet on their letterhead." & Chr(13)
strBody = strBody & "Send the info to:" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "105 MILL CREEK DRIVE" & Chr(13)
strBody = strBody & "YOUNGSVILLE NC 27596" & Chr(13)
strBody = strBody & "OR"
strBody = strBody & "you may send it as an attachment to:" & Chr(13)
strBody = strBody & "spcafc@mindspring.com" & Chr(13)
strBody = strBody & "Thank you again for helping NC's animals!" & Chr(13)
strBody = strBody & "Rebecca Rodgers" & Chr(13)
strBody = strBody & "President" & Chr(13)
strBody = strBody & "SPCA of Franklin County" & Chr(13)
strBody = strBody & "North Carolina"

myCDONTSMail.Send strFrom,strSubject,StrBody
Set myCDONTSMail = Nothing

%>


This is the response from the page:

INSERT INTO FormResults([Phone],Website,City,PhysicalAddress2,[Name],MailingAddress2,County,PhysicalCity,Fax,Email,PhysicalAddress,PhysicalZipCode,GovtDept,GovtHead,ZipCode,MailingAddress) VALUES ('0PHONE','WEBSITE','CITY','PHYSICALADDRESS2','NAME','MAILINGADDRESS2','COUNTY','PHYSICALCITY','0FAX','EMAIL','PHYSICALADDRESS','0PHYSZIPCODE','GOVTDEPT','GOVTHEAD','0ZIPCODE','MAILINGADDRESS')




BeTheBall -> RE: Can somebody check this ASP code? (5/20/2004 12:24:02)

And no error message? The response is the SQL string because you added:

response.write mySQL
response.end

Have you opened the db to see if the record updated? It appears to me that the code is now working. Take a look at the db and let us know.




spcafc -> RE: Can somebody check this ASP code? (5/20/2004 12:42:04)

quote:

ORIGINAL: betheball

And no error message? The response is the SQL string because you added:

response.write mySQL
response.end

Have you opened the db to see if the record updated? It appears to me that the code is now working. Take a look at the db and let us know.


The database did NOT update. I thought maybe removing the above code string would help but nope - here's the new error:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'DimstrBody'

/groupinfo.asp, line 42




BeTheBall -> RE: Can somebody check this ASP code? (5/20/2004 13:08:19)

You need a space between Dim and strBody. This is your code now:

Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
DimstrBody

It should be:

Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
Dim strBody




spcafc -> RE: Can somebody check this ASP code? (5/20/2004 13:45:10)

ok I think we may be getting close to fixing this. New error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/groupinfo.asp, line 66




BeTheBall -> RE: Can somebody check this ASP code? (5/20/2004 15:02:55)

Your CDONTS script is not complete. Replace this code:

Dim myCDONTSMail 
Dim strFrom 
Dim strTo 
Dim strSubject 
DimstrBody 

strFrom="spcafc@mindspring.com" 
strTo=Request.Form("MailingInformation_Email") 

strSubject = "Thank You! NC Animal Welfare Directory Submission" 
strBody="Thank you for sending your information - it will be added to/updated in our database." & Chr(13) 
strBody = strBody & "Please remember the following:" & Chr(13) 
strBody = strBody & "If you are a 501(c)3 organization please send a copy of the FIRST page of your IRS certification letter" & Chr(13) 
strBody = strBody & "OR" & Chr(13) 
strBody = strBody & "if NOT a 501(c)3 than a letter from your main vet on their letterhead." & Chr(13) 
strBody = strBody & "Send the info to:" & Chr(13) 
strBody = strBody & "SPCA of Franklin County" & Chr(13) 
strBody = strBody & "105 MILL CREEK DRIVE" & Chr(13) 
strBody = strBody & "YOUNGSVILLE NC 27596" & Chr(13) 
strBody = strBody & "OR" 
strBody = strBody & "you may send it as an attachment to:" & Chr(13) 
strBody = strBody & "spcafc@mindspring.com" & Chr(13) 
strBody = strBody & "Thank you again for helping NC's animals!" & Chr(13) 
strBody = strBody & "Rebecca Rodgers" & Chr(13) 
strBody = strBody & "President" & Chr(13) 
strBody = strBody & "SPCA of Franklin County" & Chr(13) 
strBody = strBody & "North Carolina" 

myCDONTSMail.Send strFrom,strSubject,StrBody 
Set myCDONTSMail = Nothing 


With this:

Dim myCDONTSMail 
Dim strFrom 
Dim strTo 
Dim strSubject 
Dim strBody 

Set myCDONTSMail = Server.CreateObject("CDONTS.NewMail")

strFrom="spcafc@mindspring.com" 
strTo=Request.Form("MailingInformation_Email") 

strSubject = "Thank You! NC Animal Welfare Directory Submission" 
strBody="Thank you for sending your information - it will be added to/updated in our database." & Chr(13) 
strBody = strBody & "Please remember the following:" & Chr(13) 
strBody = strBody & "If you are a 501(c)3 organization please send a copy of the FIRST page of your IRS certification letter" & Chr(13) 
strBody = strBody & "OR" & Chr(13) 
strBody = strBody & "if NOT a 501(c)3 than a letter from your main vet on their letterhead." & Chr(13) 
strBody = strBody & "Send the info to:" & Chr(13) 
strBody = strBody & "SPCA of Franklin County" & Chr(13) 
strBody = strBody & "105 MILL CREEK DRIVE" & Chr(13) 
strBody = strBody & "YOUNGSVILLE NC 27596" & Chr(13) 
strBody = strBody & "OR" 
strBody = strBody & "you may send it as an attachment to:" & Chr(13) 
strBody = strBody & "spcafc@mindspring.com" & Chr(13) 
strBody = strBody & "Thank you again for helping NC's animals!" & Chr(13) 
strBody = strBody & "Rebecca Rodgers" & Chr(13) 
strBody = strBody & "President" & Chr(13) 
strBody = strBody & "SPCA of Franklin County" & Chr(13) 
strBody = strBody & "North Carolina"    

myCDONTSMail.To=strTo
myCDONTSMail.From=strFrom
myCDONTSMail.Subject=strSubject
myCDONTSMail.Body=strBody
myCDONTSMail.Send

Set myCDONTSMail = Nothing 




spcafc -> RE: Can somebody check this ASP code? (5/20/2004 17:57:33)

THANK YOU THANK YOU THANK YOU!!!!!

Both of you have been a huge help with this.

BTW I just wanted to let you know where this bit of code came from: the website you sent me too (http://www.frontpagehowto.com/dbandemail.htm) which sent me to a microsoft white paper. Which is obviously written wrong as I did a direct copy from the white paper to the asp page. So you may want to pass that along. Also feel free to direct people to this topic as it really helped me see what small bits and pieces I needed to correct to get the code to work and helped give me a basic grounding in the code.

Thanks again guys - you're both a life saver for this small humble non profit!

Rebecca Rodgers
President
SPCA of Franklin County
North Carolina




rikki -> RE: Can somebody check this ASP code? (6/1/2004 22:48:15)

Didn't work..
Still get that insert into error

I've check and double checked all the fields with the database... they match




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.125