Problemas con MySQL timestamp y VB.Net

mysql, vb.net No Comments

Estuve a las vueltas a la hora de recuperar valores de un campo timestamp de una DB MySQL desde VB.Net.

En algunas ocasiones me devolvía este error: Unable to convert MySQL date/time value to System.DateTime.

El problema se da solo cuando nuestro registro no tiene valor para el campo timestamp. Es decir, su valor es: “0000-00-00″.

Para solucionar este pequeño inconveniente podemos hacer alguna de las siguientes modificaciones:

1) Setear un valor timestamp válido, a todos los registros cuyo timestamp no representa una fecha real.

o …

2) Agregar: Allow Zero Datetime=true al ConnectionString :


Dim strConnString As String

strConnString = "server=" & Settings.Default.host & "; " & _
"user id=" & Settings.Default.user & "; " & _
"password=" & Settings.Default.password & "; " & _
"database=" & Settings.Default.db & ";" & _
"Allow Zero Datetime=True;"
Designed By Lisandro Grassini. Powered by WordPress
Entries RSS Log in