views:

366

answers:

1

Doctrine ORM 1.0 inserts Datetime values in ISO8601 format; that is: '2009-10-23 12:31:22', but for some reason using SQL Server 2008 Express as my DB, throws an exception as if the value inserted was NULL. Here's the query:

{sfDoctrineLogger} executeQuery : INSERT INTO [vbif_inventarios] ([anulado], [id_restaurante], [fecha_inventario]) VALUES (?, ?, ?) - (0, 1, 2009-10-29 06:06:00 )

The column [fecha_inventario] is a DATETIME column.

Which gives me:

[err] {Doctrine_Connection_Mssql_Exception} SQLSTATE[HY000]: General error: 10007 No se puede insertar el valor NULL en la columna 'fecha_inventario', tabla 'vbif_operativo.dbo.vbif_inventarios'. La columna no admite valores NULL. Error de INSERT. [10007] (severity 5) [(null)]

Trying to manually insert the same string in the datefield (A query through SQL Manager) column does not work either, is there a way i can make SQL Server to accept these Strings correctly? i've read that it does support them.

+2  A: 

You need to quote the date string.

INSERT INTO [vbif_inventarios] ([anulado], [id_restaurante], [fecha_inventario]) VALUES (?, ?, ?) - (0, 1, '2009-10-29 06:06:00' )
RedFilter

related questions