Zdravim :)
mam takyto kod
Contact contact = new Contact();
contact.ContactID = (int)reader["ContactID"];
contact.ContactName = (string)reader["ContactName"];
contact.ContactSurname = (string)reader["ContactSurname"];
if (reader["MobilePhoneNo"] == DBNull.Value)
contact.MobilePhoneNo = "Nezname";
else
contact.MobilePhoneNo = (string)reader["MobilePhoneNo"];
if (reader["HomePhoneNo"] == DBNull.Value)
contact.HomePhoneNo = "Nezname";
else
contact.HomePhoneNo = (string)reader["HomePhoneNo"];
if (reader["WorkPhoneNo"] == DBNull.Value)
contact.WorkPhoneNo = "Nezname";
else
contact.WorkPhoneNo = (string)reader["WorkPhoneNo"];
if (reader["OtherPhoneNo"] == DBNull.Value)
contact.OtherPhoneNo = "Nezname";
else
contact.OtherPhoneNo = (string)reader["OtherPhoneNo"];
#endregion
contacts.Add(contact);
Chcem sa spytat, preco mi nikdy nezmeni hodnoty null na "Nezname". Co som sa docital, tak ak DataReader narazi v DB na null, vracia DBNull.Value, ale nefunguje mi to. Prehliadol som nieco ?