[BNM] ASP Help

Alan Braddish alan at webspoke.co.uk
Fri Apr 25 12:58:20 BST 2008


Hi Toby,

Firstly, it's often easier if you put the SQL string into it's own variable
before passing it through to the conn.Execute() function.  Makes it easier
to read.

Make sure that in your string parameters, you double up any single quotes,
using the replace() string function.  That's a common issue with INSERT
statements.

Hope that helps.
Alan


-----Original Message-----
From: bnmlist-bounces at brightonnewmedia.org
[mailto:bnmlist-bounces at brightonnewmedia.org] On Behalf Of Toby
Sent: 25 April 2008 12:48
To: Brighton New Media
Subject: [BNM] ASP Help

Hi all,

I'm trying to create an ASP script that will submit some posted data from a
form to an Access DB (I have no choice but to use Access).
I'm not too familiar with ASP.

I keep getting this error

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
*/***/*****/***/*****/*****/voc_confirmed_1.asp, line 26*

I dont get it at all

Could some kind soul shed some light on it?

Heres the code, the bold line seems to be the culprit

Cheers

Toby

<%
Dim conn

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("db_voc.mdb")

Dim Datum
Datum = DateAdd("h",9,now)


strKategori = trim(request.Form("category"))
strBeskriv = trim(Request.Form("comment"))
strPrio = trim(Request.Form("priority"))
strAntal = trim(Request.Form("cust"))
'Datum hämtas från Servern
strNamn = trim(Request.Form("name"))
strUnit = trim(Request.Form("date"))


If strUnit = "" Then
Response.Redirect "bad_entry.asp"
End If


*conn.Execute("INSERT INTO dbo.VOC
(category,comment,priority,cust,name,date,Unit) VALUES " & "('" &
strKategori & "','" & strBeskriv & "','" & strPrio & "','"  & strAntal &
"','" & Datum & "','" & strNamn & "','" & strUnit & "')")*


conn.close

%>






-- 
Front End Web Developer
-- 

BNM Subscribe/Unsubscribe:
http://www.brightonnewmedia.org/options/bnmlist

Archive Search - http://icanhaz.com/bnmarchive

BNM powered by Wessex Networks:
http://www.wessexnetworks.com



More information about the BNMlist mailing list. Powered by Wessex Networks