Posted on: 7/30/2015 4:02:26 AM | Views : 895

when i try to retrieve data from database it become problem when the data stored is NULL.. 
for normal string i use this code 
Me.tbOtherDet.Text = IIf(Not IsDBNull(dr("OtherHSDet")), dr("OtherHSDet"), " ").ToString and it work fine
but when there is date type data that i want to retrieve i use the these two type code and return "Conversion from type 'DBNull' to type 'String is not valid.'"
1) Me.tbReceiveAdmin.Text = IIf(Not IsDBNull(dr("AdminReceiveDate")), Date.ParseExact(dr("AdminReceiveDate"), "d/M/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo), String.Empty) 2) Me.tbReceiveAdmin.Text = IIf(Not IsDBNull(dr("AdminReceiveDate")), Date.ParseExact(dr("AdminReceiveDate"), "d/M/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo), " ").To ...

Go to the complete details ...