Error classic asp and oracle dates

2

I'm having a problem inserting a date and time into a database. I am using asp classic and the database is oracle. The code I am using is the following

 Set conn = Server.CreateObject("ADODB.Connection")
             conn.Open conexion
             sql = "insert into tabla ("
             sql = sql & "campo1,campo2,fecha_hora,campo3,campo4,campo5)"
             sql = sql & " values('"
             sql = sql & valor1& "','" & valor2 & "','" & now & "','" & valor3 & "','" & valor 4 & "','Cadena')"
             conn.Execute(sql)

And when executing it, it shows me the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Oracle][ODBC][Ora]ORA-01830: la máscara de formato de fecha termina antes de convertir
toda la cadena de entrada

Can someone help me?

    
asked by APJ 17.07.2017 в 10:18
source

1 answer

0

The date format of the application is incompatible with that of the database. This can be corrected by formatting or in a simpler way if you are looking to store the current date and time.

You could try it in the following way:

 Set conn = Server.CreateObject("ADODB.Connection")
         conn.Open conexion
         sql = "insert into tabla ("
         sql = sql & "campo1,campo2,fecha_hora,campo3,campo4,campo5)"
         sql = sql & " values('"
         sql = sql & valor1& "','" & valor2 & "', sysdate,'" & valor3 & "','" & valor 4 & "','Cadena')"
         conn.Execute(sql)

with sysdate you would be storing the current date and time of the server in your field.

    
answered by 17.07.2017 / 14:23
source