mckenzie Posted February 2, 2006 Share Posted February 2, 2006 this error occurs when trying to write to a database!Syntax error in INSERT INTO statementheres the code:<!--#include file="includes/head.asp"--><table width="700" cellpadding="4" cellspacing="4" border="1" align="left" class="text2"> <!--#include file="includes/masthead.asp"--> <tr> <td width="150" valign="top"> <!--------left navi bar--------> <!--#include file="includes/left_navi.asp"--> <td width="0" valign="top"> <!--------Central Content--------><% dim conn set conn = Server.CreateObject("ADODB.connection") conn.Open "PROVIDER=Microsoft.jet.oledb.4.0;DATA SOURCE=" & server.MapPath("Features.mdb") & ";" dim id id = request("id") dim sql 'step 1 - make sql statement Sql = "insert into feedback(lastname, firstname, email, telephone, age, ######, helpfullness, appeal, use, quality, suggestions, focus, history, hair, triathlon, koiPondsGardens, subscribe)" Sql = Sql & "values('" & request("lname") & "'," Sql = Sql & "'" & request("fname") & "'," Sql = Sql & "'" & request("email") & "'," Sql = Sql & "'" & request("tel") & "'," Sql = Sql & request("age") & ", " Sql = Sql & "'" & request("######") & "'," Sql = Sql & "'" & request("helpfulness") & "'," Sql = Sql & "'" & request("visual_appeal") & "'," Sql = Sql & "'" & request("use") & "'," Sql = Sql & "'" & request("quality") & "'," Sql = Sql & "'" & request("suggestions") & "'," 'loop through the 5 magazines to add them into the database for i = 1 to 5 if request("magazine"&i) = "1" then Sql = Sql & "true, " else Sql = Sql & "false, " end if next 'check that the subscribe checkbox was checked if request("intColumn2") = "1" then Sql = Sql & "true) " else Sql = Sql & "false) " end if response.write "sql=" & sql conn.execute(sql) %> <table width="400" cellpadding="10" cellspacing="10" border="0" align="left" class="text3"> <tr> <td align="center"><h2>THANKYOU FOR YOUR CONTRIBUTION!</h2><br><br></td> </tr> <tr> <td align="center"><h3>Your Comments will be examined carefully</h3></td> </tr> <tr> <td align="center" class="text1"><h4>Click <a href="default.asp" title="Home Page"><b>here</b></a> to return to the Home Page</<h4></td> </tr> </table> <td width = "140" valign="top"></td> <!--End Central Content--> <!--------Affiliates--------> <!--#include file="includes/Affil.asp"--> <td width="15" valign="top"></table> Link to comment Share on other sites More sharing options...
aspnetguy Posted February 2, 2006 Share Posted February 2, 2006 comment out the execute line response.write "sql=" & sql'conn.execute(sql) Then post the result of the response.write(Sql) Link to comment Share on other sites More sharing options...
mckenzie Posted February 2, 2006 Author Share Posted February 2, 2006 i think it worked.dim conn sql=insert into feedback(lastname, firstname, email, telephone, age, ######, helpfullness, appeal, use, quality, suggestions, focus, history, hair, triathlon, koiPondsGardens, subscribe)values('','','e-mail','',, '','-','-','-','-','',false, false, false, false, false, true)it provided this information!sorry i'm a newbie i'm jus gonna check my database Link to comment Share on other sites More sharing options...
aspnetguy Posted February 2, 2006 Share Posted February 2, 2006 it did not work...I just needed that info to help debug.Is your database set to allow null entries in lastname, firstname, etc..fields that are currently null???Another possible problem is age...if you are trying to insert NULL into a number field...BTW what DB are you using? Access? Link to comment Share on other sites More sharing options...
mckenzie Posted February 2, 2006 Author Share Posted February 2, 2006 its access and how would i go about setting the database to accept null Link to comment Share on other sites More sharing options...
aspnetguy Posted February 2, 2006 Share Posted February 2, 2006 Unless you set it as a required field and it is not a Primary or Foreign key it already accepts null.What is the Primary Key of the table? Are any of the fields required fields (if you did not set them as required they are not)?Is the age field a number or text (string)???? Link to comment Share on other sites More sharing options...
netcracker Posted February 7, 2006 Share Posted February 7, 2006 its access and how would i go about setting the database to accept null<{POST_SNAPBACK}> read the tutorials !or the help in MSAccess [press F1 ] !u might as well use GOOGLE Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now