I have the following code
String sqlQuery = "SELECT * FROM table";
SqlCeDataReader reader = ConectorSQLCE.consultar(rutaArchivo, sqlQuery);
String value = "";
try
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
if (reader.GetValue(i) == DBNull.Value)
value += "*";
else
{
value += reader.GetValue(i).ToString();
}
}
}
}
When reader.GetValue(i)
is a datetime
field, sometimes it returns 01/01/2014 0:00:00
and other times returns 01/01/2014 12:00:00 a.m.
Why does this happen? The string value is used then to a hash code, so I have for the same row different hashes.
Not sure why it would do that, but if the time field is always the same, why don't you just convert it to a
.ShortDateString()
, then you don't have to worry about inconsistencies. You can also convert it on the sql side if you call each column you need by name and use aconvert(varchar,dateField,101)