Je développe mon premier programm et je suis confronté à des problèmes s'il vous plaît aidez-moi terminer je le code en C#:Impossible de convertir implicitement le type 'objet' en 'System.DateTime'. Il existe une conversion explicite (vous manque un casting?)
SqlDataReader dr = null;
dr = cmd.ExecuteReader();
if (dr.Read())
{
client_id = dr["clientid"].ToString();
surname = dr["surname"].ToString();
othername = dr["othername"].ToString();
gender = dr["gender"].ToString();
date_ofbirth = dr["dateofbirth"];
nationality = dr["nationality"].ToString();
//age = dr["Age"];
residential_address = dr["residentialaddress"].ToString();
postal_address = dr["postaladdress"].ToString();
contact_number = dr["telephonenumber"].ToString();
marital_status = dr["maritalstatus"].ToString();
spouse_name = dr["spousename"].ToString();
email = dr["email"].ToString();
occupation = dr["occupation"].ToString();
typeof_id = dr["typeofid"].ToString();
id_number = dr["idnumber"].ToString();
id_expirydate = dr["idexpirydate"];
remarks = dr["remarks"].ToString();
picture = dr["picture"].ToString();
return true;
cmd.CommandText = null;
}
et le message d'erreur c'est ............... date_ofbirth = dr ["dateofbirth"]; Erreur 2 Impossible de convertir implicitement le type 'objet' en 'System.DateTime'. Une conversion explicite existe
(vous manque un casting?)
C: \ Users \ MICKY \ Documents \ Visual Studio 2008 \ Projects \ Godswill \ Godswill \ Personal.cs 249 28 Godswill
Petit truc que j'ai passé 15 minutes sur: dapper lancera la même erreur si votre classe n'est pas publique, mais privée. Un peu obscur. –