retriving 2 o more Date Fields in select statement
Posted: Wed 12 Jul 2006 21:38
Hi,
This is the most weird that ever happened to me.
When i use a select statement like this.
"select id, destino, ";
sql += "mensaje, usuario, fecha_envio, fecha_pos, fecha_smsc,cliente, ";
sql += "id_smsc, id_estado from mensajes ";
sql += "where id_estado = @id_estado ";
sql += "order by usuario, fecha_pos, mensaje";
and use a DataReader object for retreiving those data including date values
command.CommandText = sql;
command.Parameters.Add("@id_estado",PgSqlType.Numeric).Value = idState;
messageReader = command.ExecuteReader();
while (messageReader.Read())
{
messageReader.GetDateTime(2) /*for retriving fecha_envio*/
/* and the fetching is ok por fecha_envio*/
messageReader.GetDateTime(3) /*fecha_pos for retriving */
/* Reader fails retrieving fecha_pos because 2 o more consecutive dates can not be retrieved consecutive*/
messageReader.GetDateTime(4) /* fecha_smsc for retriving */
/* Reader fails retrieving fecha_smsc because 2 o more consecutive dates can not be retrieved consecutive*/
}
Also if I use de function IsDBNull the same happens, the solution was mix others fields in the middle of Date Type Fields.
This is the most weird that ever happened to me.
When i use a select statement like this.
"select id, destino, ";
sql += "mensaje, usuario, fecha_envio, fecha_pos, fecha_smsc,cliente, ";
sql += "id_smsc, id_estado from mensajes ";
sql += "where id_estado = @id_estado ";
sql += "order by usuario, fecha_pos, mensaje";
and use a DataReader object for retreiving those data including date values
command.CommandText = sql;
command.Parameters.Add("@id_estado",PgSqlType.Numeric).Value = idState;
messageReader = command.ExecuteReader();
while (messageReader.Read())
{
messageReader.GetDateTime(2) /*for retriving fecha_envio*/
/* and the fetching is ok por fecha_envio*/
messageReader.GetDateTime(3) /*fecha_pos for retriving */
/* Reader fails retrieving fecha_pos because 2 o more consecutive dates can not be retrieved consecutive*/
messageReader.GetDateTime(4) /* fecha_smsc for retriving */
/* Reader fails retrieving fecha_smsc because 2 o more consecutive dates can not be retrieved consecutive*/
}
Also if I use de function IsDBNull the same happens, the solution was mix others fields in the middle of Date Type Fields.