Error in INSERT query, please help!

  • Thread starter Thread starter Teo
  • Start date Start date
T

Teo

Hi!
I am using ColdFusion to run a query in an Access Database.

Below is the query. For some reason, it is giving me a syntax error in the
INSERT statement. For what I know I have it written down correctly.
Please let me know what could be wrong,
Thanks much, code is below.

ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][Controlador ODBC Microsoft Access] Error de sintaxis en la
instrucción INSERT INTO.


SQL = "INSERT Cotizacion(Documento, Tipo,Cliente, Numero_Pasaporte,
Fecha_Cotizacion, Periodo, Año,Vendedor, Forma_de_pago,Cheque_Cobro) VALUES
('433A','ORO','569','34324242',12-Mar-04,'03','2004','1', '2',)"

Teo
 
Have you tried INSERT INTO, rather than just INSERT?
Also you could try putting # either side of the date.

ie

SQL = ""
SQL + SQL & "INSERT INTO Cotizacion "
SQL + SQL & "(Documento, Tipo,Cliente, Numero_Pasaporte,"
SQL + SQL & "Fecha_Cotizacion, Periodo, Año,Vendedor,
Forma_de_pago,Cheque_Cobro)"
SQL + SQL & " VALUES "
SQL + SQL & " ('433A','ORO','569','34324242',#12-Mar-04#,'03','2004','1',
'2',)"
 
Keep getting the same error :-(
I don't know what else could be wrong. I added INSERT INTO instead of just
INSERT and tried having the ## around the date.
Still no luck,

Teo
 
Don't know if it is transcription error when writing this post, but I just
noticed a comma (',') right at the end of your INSERT statement (just before
the last ')'

ChrisM
 
You've listed 10 fields to update, but you only have 9 values. Instead of a
value for Cheque_Cobro, you've got nothing after the last comma.

Either remove Cheque_Cobro from the list of fields (and don't have that ,
last comma), or pass Null as the last value:

SQL = "INSERT Cotizacion(Documento, Tipo,Cliente, Numero_Pasaporte,
Fecha_Cotizacion, Periodo, Año,Vendedor, Forma_de_pago)
VALUES
('433A','ORO','569','34324242',#12-Mar-04#,'03','2004','1', '2')"

or

SQL = "INSERT Cotizacion(Documento, Tipo,Cliente, Numero_Pasaporte,
Fecha_Cotizacion, Periodo, Año,Vendedor, Forma_de_pago,Cheque_Cobro)
VALUES
('433A','ORO','569','34324242',#12-Mar-04#,'03','2004','1', '2',Null)"

Also, the statements above assume that none of your fields are numeric: that
they're all text (except for Periodo, which is a date). If any of the fields
are actually defined as numeric, remove the quotes around the value for that
particular field.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Teo said:
Keep getting the same error :-(
I don't know what else could be wrong. I added INSERT INTO instead of just
INSERT and tried having the ## around the date.
Still no luck,

Teo
Teo said:
Hi!
I am using ColdFusion to run a query in an Access Database.

Below is the query. For some reason, it is giving me a syntax error in the
INSERT statement. For what I know I have it written down correctly.
Please let me know what could be wrong,
Thanks much, code is below.

ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][Controlador ODBC Microsoft Access] Error de sintaxis en la
instrucción INSERT INTO.


SQL = "INSERT Cotizacion(Documento, Tipo,Cliente, Numero_Pasaporte,
Fecha_Cotizacion, Periodo, Año,Vendedor, Forma_de_pago,Cheque_Cobro) VALUES
('433A','ORO','569','34324242',12-Mar-04,'03','2004','1', '2',)"

Teo
 
Yeah, well, that ruled out that problem, now I get the
"Too few paramenters, 2 expected"
Any other suggestions.

Thanks much so far for everything guys
Teo
ChrisM said:
Don't know if it is transcription error when writing this post, but I just
noticed a comma (',') right at the end of your INSERT statement (just before
the last ')'

ChrisM

Teo said:
Hi!
I am using ColdFusion to run a query in an Access Database.

Below is the query. For some reason, it is giving me a syntax error in the
INSERT statement. For what I know I have it written down correctly.
Please let me know what could be wrong,
Thanks much, code is below.

ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][Controlador ODBC Microsoft Access] Error de sintaxis en la
instrucción INSERT INTO.


SQL = "INSERT Cotizacion(Documento, Tipo,Cliente, Numero_Pasaporte,
Fecha_Cotizacion, Periodo, Año,Vendedor, Forma_de_pago,Cheque_Cobro) VALUES
('433A','ORO','569','34324242',12-Mar-04,'03','2004','1', '2',)"

Teo
 
TEO,

I see your problem. You are passing it too few parameters. In the first part
of your INSERT statement
INSERT *****(*,***,***)
You have 10 parameters you are telling it you will be passing. However, you
are only passing 9 in your VALUES part of the code.
You only need to declare the number of parameters or fields which you want
to set when creating the new record. It isn't necessary to insert
everything.

Hope this helps,
Chris P.


Teo said:
Yeah, well, that ruled out that problem, now I get the
"Too few paramenters, 2 expected"
Any other suggestions.

Thanks much so far for everything guys
Teo
ChrisM said:
Don't know if it is transcription error when writing this post, but I just
noticed a comma (',') right at the end of your INSERT statement (just before
the last ')'

ChrisM

Teo said:
Hi!
I am using ColdFusion to run a query in an Access Database.

Below is the query. For some reason, it is giving me a syntax error in the
INSERT statement. For what I know I have it written down correctly.
Please let me know what could be wrong,
Thanks much, code is below.

ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][Controlador ODBC Microsoft Access] Error de sintaxis en la
instrucción INSERT INTO.


SQL = "INSERT Cotizacion(Documento, Tipo,Cliente, Numero_Pasaporte,
Fecha_Cotizacion, Periodo, Año,Vendedor, Forma_de_pago,Cheque_Cobro) VALUES
('433A','ORO','569','34324242',12-Mar-04,'03','2004','1', '2',)"

Teo
 
Back
Top