Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in INSERT INTO statement 1

Status
Not open for further replies.

bjm027

MIS
Mar 7, 2003
59
US
I am getting an error with the syntax of my Insert statement. I tried it with just a couple of fields first (this worked) and then when I added all of the fields I needed, it of course wont work now.
If anyone can see something wrong with my insert into statement please help.
I had wordwrap on when I pasted it.
Any Help appreciated.....


<%
Function Change(strDesc)
'This function replace a single apostrophe with a ^ so the field can be saved to the database.
Change = strDesc
Change = Replace(Change, &quot;'&quot;, &quot;^&quot;)
End Function
%>

<%
Dim Conn
Dim strSQL
SET Conn = server.createobject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;MyDataBase&quot;

strSQL = &quot;INSERT INTO Survey(Social Activities, Other Types, Professional Development, Other Types 2, Community Involvement, Charities, In Mind for Future, Remove, Skills and Talents) VALUES ('&quot;+ Change(Request.Form(&quot;Social Activities&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;Other Types&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;Professional Development&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;Other Types 2&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;Community Involvement&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;Charities&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;In Mind for Future&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;Remove&quot;)) +&quot;', '&quot;+ Change(Request.Form(&quot;Skills and Talents&quot;)) +&quot;')&quot;

Conn.Execute(strSQL)
 
Right before you do the execute:
response.write(strSQL)
response.end()
Conn.Execute(strSQL)
 
Sorry about yesterday. I had a hard time getting back into the tek-tips site, so I decided just to call it quits yesterday.

Veep,
Hope your still around, but I tried what you said in the previous post and got this:
-------
INSERT INTO Survey([Social Activities], [Other Types], [Professional Development], [Other Types 2], [Community Involvement], [Charities], [In Mind for Future], [Remove], [Skills and Talents]) VALUES ('', '', '', '', '', '', '', '', '')
--------
And it is still inserting empty strings for all of the values into my database.


onpt,
I tried changing the +'s to &'s and got the same results.

I think I am going to go back and recheck all the names throughout everything, come up with better names (no spaces), and try it over again. Ill let you know if anything works.
But if anyone sees something else I havnt caught, let me know.
Thanks to everyone for their help.
 
Add this to the top of your page:
<%
for each objItem in request.form()
response.write(objItem & &quot; = &quot; & request.form(objItem) & &quot;<br>&quot;
Next
response.end
%>

This will allow you to see the name/value for each item that is coming over from your post.
 
Well it seems to be it wasnt the ASP at all. That works fine. On my survey.asp page i had this under the form tag:
-----
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;testsurveysave.asp&quot; enctype=blahblah>
-----

The blahblah is there because i dont remember what was there, but it was definitly affecting it. Well, anyways I changed it to this and everything worked fine.

This is what I changed the form tag to:
-----
<form method=&quot;post&quot; action=&quot;testsurveysave.asp&quot;>
-----

Thanks a bunch for everyones input. I still learned things about asp which is why I come to this forum.
 
Enctype will do that to you. [hammer] Glad you're getting something out of the forum.
 
I have to give Veep a star for sticking with me.
I am not familier with 'Enctype', what does that do?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top