I am writing a web application with Visual Studio 2005 and PostgreSQL. In my database I have a table with a TIMESTAMP field WITHOUT TIMEZONE which I tried to fill with the Date.Now function of Visual Basic 2005; this function returns the actual date and time with an aggregate of "a.m." or "p.m." at the end. When an INSERT is issued to the database I get the following error message:
***** timezone "a.m." not recognized *****
I checked the type of exception and I get "corelab.postgresql.pgsqlexception".
Am I doing something wrong?
My version of PostgreSQLDirect.NET is 3.75.31.0
P.D.
If I change the time format in Regional Settings to be displayed in a 0-24 option then everything works as expected.
With respect,
Jorge Maldonado
DATE AND TIME WITHOUT TIMEZONE
Here is the code. It is part of a class; it's a method that inserts a record to a PostgreSQL log table which receives several parameters being Fecha of type Timestamp in the database.Shalex wrote:Please send us (alexsh at devart.com) your code where you create the object of the CoreLab.PostgreSQL.PgSqlCommand class and call its method. We need to know the way you transfer the result of the Date.Now function to your PostgreSQL database.
Public Shared Sub NuevoEvento(ByVal UserId As String, ByVal Fecha As DateTime, _
ByVal Ubicacion As String, ByVal Detalle As String, _
ByVal Mensaje As String, ByVal Tipo As String, ByVal Stack As String)
Try
Dim strConn As String = ConfigurationManager.ConnectionStrings("PgSqlConnection").ConnectionString
Dim pgConn As New PgSqlConnection(strConn)
Dim strQuery As String
strQuery = "INSERT INTO Eventos (Fecha, UserId, Ubicacion, Detalle, Mensaje, Tipo, Stack) "
strQuery = strQuery + "VALUES ('" + Date.Now + "', '" + UserId + "', '" + Ubicacion + "', '"
strQuery = strQuery + Detalle + "', '" + Mensaje + "', '" + Tipo + "', '" + Stack + "')"
Dim pgCmd As New PgSqlCommand(strQuery, pgConn)
pgConn.Open()
If pgCmd.ExecuteNonQuery() = 0 Then
Utilerias.DespliegaMensaje("Ha ocurrido un error al insertar el registro en archivo de EVENTOS.")
'Else
'Utilerias.DespliegaMensaje("Se ha insertado el registro de eventos satisfactoriamente.")
End If
pgConn.Close()
Catch ex As Exception
Utilerias.DespliegaMensaje(ex.Message + "\n \n" + ex.GetType().ToString + "\n \n")
End Try