Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: SV: Probs with INSERT SQL


Message #1 by =?iso-8859-1?Q?H=E5kan_Frennesson?= <hakan@c...> on Wed, 14 Nov 2001 16:43:53 +0100
Hi!



You should rename your field "Name" to something else.

Hakan



-----Ursprungligt meddelande-----

Från: Colin Montgomery [mailto:colin.montgomery@c...]

Skickat: den 14 november 2001 12:05

Till: ASP Databases

Ämne: [asp_databases] Probs with INSERT SQL





Hi



I've got a simple page taking form variables and inserting them into an

Access 97 db, via a conn string:



Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=C:\IntranetSiteFiles\EnquiriesFeedback\Feedback.mdb;Persist

Security Info=False



I'm getting a 'Syntax error in INSERT INTO statement' error.



When I Response.Write the SQL I get:



INSERT INTO tblFeedback

     (Name, position, office, practice, timewithfacm,

      usedesk, notusedesk, useother, deskfreq, enquirytype,

      othertype, rating, othercomments)

VALUES

      ('myname', 'manager', 'London', 'finance',

       'less than 1 year', 'yes',

       'intranet, otherlawyers',

       'other', 'occasionally',

       'templates, transbibles, knowhow casesorlegislation',

       'other', 'excellent', 'other')



However when I run it in Access' query builder it runs fine.



I'm baffled - can anyone help?



For info i've included my code below (appologies for wrapping).



Thanks,

Colin



<% @Language=VBScript %>

<%

option explicit

response.expires = 0

%>

<!--#include file="Connections/connFeedback.asp" -->

<%

Dim strName, strPosition, strOffice, strGroup, strTimeWithFaCM

Dim strUseDesk, strNotUseDesk, strUseOther, strDeskFreq

Dim strEnquiryType, strOtherType, strRateDesk, strOtherComments

Dim strSQL, comInsertFeedback



'get all variables from Forms Collection

strName = Request.Form("Name")

strPosition = Request.Form("Position")

strOffice = Request.Form("Office")

strGroup = Request.Form("Group")

strTimeWIthFacm = Request.Form("timeWithFaCM")

strUseDesk = Request.Form("usedesk")

strNotUseDesk = Request.Form("notusedesk")

strUseOther = Request.Form("useother")

strDeskFreq = Request.Form("deskfreq")

strEnquiryType = Request.Form("enquirytype")

strOtherType = Request.Form("othertype")

strRateDesk = Request.Form("ratedesk")

strOtherComments = Request.Form("othercomments")



strSQL = "INSERT INTO tblFeedback " _

	   & "(Name, position, office, practice, timewithfacm, " _

	   & "usedesk, notusedesk, useother, deskfreq, enquirytype, " _

	   & "othertype, rating, othercomments) " _

	   & "VALUES ('" & strName & "', '" & strPosition & "', '" &

strOffice _

	   & "', '" & strGroup & "', '" & strTimeWithFaCM & "', '" &

strUseDesk _

	   & "', '" & strNotUseDesk & "', '" & strUseOther & "', '" &

strDeskFreq _

	   & "', '" & strEnquiryType & "', '" & strOtherType & "', '" &

strRateDesk _

	   & "', '" & strOtherComments & "')"



response.write strSQL



set comInsertFeedback = Server.CreateObject("ADODB.Command")

comInsertFeedback.ActiveConnection = MM_connFeedback_STRING

comInsertFeedback.CommandText = strSQL

comInsertFeedback.CommandType = 1

comInsertFeedback.CommandTimeout = 0

comInsertFeedback.Prepared = true

comInsertFeedback.Execute()



comInsertFeedback.Close

set comInsertFeedback = Nothing

%>











  Return to Index