473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Syntax error in INSERT INTO statement

ACCESS
First fields are TEXT, last 2 are Numbers
The name of the fields are correct.
Dim MyConn
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath
("/xdata/sc.mdb")

Sql = "INSERT INTO sc (" & _
"session,sessionLanguage,sessionProductReferentie, " & _
"sessionProductGroep,sessionProductSubGroep," & _
"sessionProductTaal1,sessionProductTaal2,sessionPr oductTaal3," & _
"sessionProductAantal,sessionProductWKP)" & _
" VALUES (" & _
Chr(34) & Application("id") & Chr(34) & "," & _
Chr(34) & Request.form("taal") & Chr(34) & "," & _
Chr(34) & Request.form("referentie") & Chr(34) & "," & _
Chr(34) & Request.form("groep") & Chr(34) & "," & _
Chr(34) & Request.form("subgroep") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal1"),Chr(34)," ") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal2"),Chr(34)," ") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal3"),Chr(34)," ") & Chr(34) & "," & _
Request.form("aantal") & "," & _
Replace(Request.form("wkp"),",",".") & ")"

MyConn.Execute sql
Set MyConn=Nothing

If i print the SQL string it looks like:

INSERT INTO sc
(session,sessionLanguage,sessionProductReferentie, sessionProductGroep,sessionProductSubGroep,session ProductTaal1,sessionProductTaal2,sessionProductTaa l3,sessionProductAantal,sessionProductWKP)
VALUES
("81.165.236.141-1/02/2005-20:00:34-804105034","N","22102","22","10HA","GEKLOVEN
RIET","ROSEAU PAR 1/2 KG","",1,9.8)

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.

Can somebody point me what i'm doing wrong?

Thx, Gérard.

Jul 22 '05 #1
6 2172

Gérard Leclercq wrote:
ACCESS
First fields are TEXT, last 2 are Numbers
The name of the fields are correct.
Dim MyConn
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath ("/xdata/sc.mdb")

Sql = "INSERT INTO sc (" & _
"session,sessionLanguage,sessionProductReferentie, " & _
"sessionProductGroep,sessionProductSubGroep," & _
"sessionProductTaal1,sessionProductTaal2,sessionPr oductTaal3," & _
"sessionProductAantal,sessionProductWKP)" & _
" VALUES (" & _
Chr(34) & Application("id") & Chr(34) & "," & _
Chr(34) & Request.form("taal") & Chr(34) & "," & _
Chr(34) & Request.form("referentie") & Chr(34) & "," & _
Chr(34) & Request.form("groep") & Chr(34) & "," & _
Chr(34) & Request.form("subgroep") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal1"),Chr(34)," ") & Chr(34) & "," & _ Chr(34) & Replace(Request.form("taal2"),Chr(34)," ") & Chr(34) & "," & _ Chr(34) & Replace(Request.form("taal3"),Chr(34)," ") & Chr(34) & "," & _ Request.form("aantal") & "," & _
Replace(Request.form("wkp"),",",".") & ")"

MyConn.Execute sql
Set MyConn=Nothing

If i print the SQL string it looks like:

INSERT INTO sc
(session,sessionLanguage,sessionProductReferentie, sessionProductGroep,sessionProductSubGroep,session ProductTaal1,sessionProductTaal2,sessionProductTaa l3,sessionProductAantal,sessionProductWKP)
VALUES
("81.165.236.141-1/02/2005-20:00:34-804105034","N","22102","22","10HA","GEKLOVEN
RIET","ROSEAU PAR 1/2 KG","",1,9.8)

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.

Can somebody point me what i'm doing wrong?

Thx, Gérard.

Text fields in Access should be delimited by single quotes, not double
quotes.

Paxton

Jul 22 '05 #2
Use single quotes to delimit your character strings.

('81.165.236.141-1/02/2005-20:00:34-804105034',

If that doesn't help try removing columns from the statement to see which
one the system doesn't like.
--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Gérard Leclercq" <ge*************@pas-de-mail.fr> wrote in message
news:7v*****************@phobos.telenet-ops.be...
ACCESS
First fields are TEXT, last 2 are Numbers
The name of the fields are correct.
Dim MyConn
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath ("/xdata/sc.mdb")

Sql = "INSERT INTO sc (" & _
"session,sessionLanguage,sessionProductReferentie, " & _
"sessionProductGroep,sessionProductSubGroep," & _
"sessionProductTaal1,sessionProductTaal2,sessionPr oductTaal3," & _
"sessionProductAantal,sessionProductWKP)" & _
" VALUES (" & _
Chr(34) & Application("id") & Chr(34) & "," & _
Chr(34) & Request.form("taal") & Chr(34) & "," & _
Chr(34) & Request.form("referentie") & Chr(34) & "," & _
Chr(34) & Request.form("groep") & Chr(34) & "," & _
Chr(34) & Request.form("subgroep") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal1"),Chr(34)," ") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal2"),Chr(34)," ") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal3"),Chr(34)," ") & Chr(34) & "," & _
Request.form("aantal") & "," & _
Replace(Request.form("wkp"),",",".") & ")"

MyConn.Execute sql
Set MyConn=Nothing

If i print the SQL string it looks like:

INSERT INTO sc
(session,sessionLanguage,sessionProductReferentie, sessionProductGroep,sessionProductSubGroep,session ProductTaal1,sessionProductTaal2,sessionProductTaa l3,sessionProductAantal,sessionProductWKP)
VALUES
("81.165.236.141-1/02/2005-20:00:34-804105034","N","22102","22","10HA","GEKLOVEN
RIET","ROSEAU PAR 1/2 KG","",1,9.8)

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.

Can somebody point me what i'm doing wrong?

Thx, Gérard.


Jul 22 '05 #3

Double Quotes are not the reason, if have a lot of INSERTs with "". If i
alter the string without the fields it works fine. So i think, have not find
time this morning to test, that maybe the field 'session' is a reservate
word?? Gérard.

PS: Double quotes are for the namy Last Names with ' in my region, like
D'Haese or D'Hondt.
Sql = "INSERT INTO sc VALUES (" & _
Chr(34) & Application("id") & Chr(34) & "," & _
Chr(34) & Request.form("taal") & Chr(34) & "," & _
Chr(34) & Request.form("referentie") & Chr(34) & "," & _
Chr(34) & Request.form("groep") & Chr(34) & "," & _
Chr(34) & Request.form("subgroep") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal1"),Chr(34)," ") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal2"),Chr(34)," ") & Chr(34) & "," & _
Chr(34) & Replace(Request.form("taal3"),Chr(34)," ") & Chr(34) & "," & _
Request.form("aantal") & "," & _
Replace(Request.form("wkp"),",",".") & ")"

Jul 22 '05 #4
Gérard Leclercq wrote:
Double Quotes are not the reason, if have a lot of INSERTs with "". If i
alter the string without the fields it works fine. So i think,
have not find time this morning to test, that maybe the field
'session' is a reservate word?? Gérard.


http://aspfaq.com/show.asp?id=2080

A good test is to open your database in Access, create a new query in design
view without choosing a table from the dialog, switch to SQL View, paste
your sql statement in and try to run it. If it runs with no problem, then
you probably have a reserved keyword issue.

You should consider using a saved parameter query so you don't have to worry
about delimiters and apostrophes:
http://www.google.com/groups?hl=en&l...P12.phx.gblBob Barrows--Microsoft MVP - ASP/ASP.NETPlease reply to the newsgroup. This email account is my spam trap so Idon't check it very often. If you must reply off-line, then remove the"NO SPAM"

Jul 22 '05 #5
Thx Bob, as i suspected 'session'.
The other link gives me and error to the page for the saved parameters.
Gérard.

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> schreef in bericht
news:em**************@TK2MSFTNGP11.phx.gbl...
Gérard Leclercq wrote:
Double Quotes are not the reason, if have a lot of INSERTs with "". If i
alter the string without the fields it works fine. So i think,
have not find time this morning to test, that maybe the field
'session' is a reservate word?? Gérard.


http://aspfaq.com/show.asp?id=2080

A good test is to open your database in Access, create a new query in
design view without choosing a table from the dialog, switch to SQL View,
paste your sql statement in and try to run it. If it runs with no problem,
then you probably have a reserved keyword issue.

You should consider using a saved parameter query so you don't have to
worry about delimiters and apostrophes:
http://www.google.com/groups?hl=en&l...P12.phx.gblBob
Barrows--Microsoft MVP - ASP/ASP.NETPlease reply to the newsgroup. This
email account is my spam trap so Idon't check it very often. If you must
reply off-line, then remove the"NO SPAM"

Jul 22 '05 #6
Try this:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

Bob

Gérard Leclercq wrote:
Thx Bob, as i suspected 'session'.
The other link gives me and error to the page for the saved
parameters. Gérard.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
2
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error from the code below! Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint...
3
by: jinhy82 | last post by:
Hi! I am currently creating a Registration form which contained: UserID Password, FirstName and LastName. These details would be inserted into Ms Access when I click submi button. But I...
3
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41...
5
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
1
by: vasanth chandrasekaran | last post by:
The error is :Syntax error in INSERT INTO statement. This is my code: try { DataSet ds1; OleDbConnection ConnSql; OleDbConnection...
9
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
0
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.