I'm trying to convert a string that I pull from the database with the
DateTime PrevisaoDataInicio = DateTime.Parse(reader["PrevisaoDataInicio"].ToString())
And gives the following error:
String was not recognized as a valid DateTime.
The entire method where it is being used is below:
private List<EntendimentoDominio> TransformaReaderEmListaDeObjeto(SqlCeDataReader reader)
{
var entendimentos = new List<EntendimentoDominio>();
while (reader.Read())
{
var temObjeto = new EntendimentoDominio()
{
CodEntendimento = int.Parse(reader["CodEntendimento"].ToString()),
AreaResponsavel = reader["AreaResponsavel"].ToString(),
Modulo = reader["Modulo"].ToString(),
Projeto = reader["Projeto"].ToString(),
Subprojeto = reader["Subprojeto"].ToString(),
DescricaoResumida = reader["DescricaoResumida"].ToString(),
DescricaoDetalhada = reader["DescricaoDetalhada"].ToString(),
CustoEstimado = reader["CustoEstimado"].ToString(),
NomeDocumentoAnexo = reader["NomeDocumentoAnexo"].ToString(),
CaminhoDocumentoAnexo = reader["CaminhoDocumentoAnexo"].ToString(),
Status = reader["Status"].ToString(),
TempoEstimado = reader["TempoEstimado"].ToString(),
PrevisaoDataInicio = DateTime.Parse(reader["PrevisaoDataInicio"].ToString()),
PrevisaoDataFinal = DateTime.Parse(reader["PrevisaoDataFinal"].ToString())
};
entendimentos.Add(temObjeto);
}
reader.Close();
return entendimentos;
}