String was not recognized as a valid DateTime.

on Mar 20, 2012 01:03 AM

 dr("Working_Hour") = (Convert.ToDateTime(dr(4)) - Convert.ToDateTime(dr(3))) + (Convert.ToDateTime(dr(6)) - Convert.ToDateTime(dr(5))) + (Convert.ToDateTime(dr(8)) - Convert.ToDateTime(dr(7)))

here dr is data row ,

how can i remove this error

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Mar 20, 2012 01:04 AM
on Mar 20, 2012 01:05 AM

This error comes due to following reasons

1. The value returned from database is NULL

2. The value returned has some spaces

3. The value returned is not valid datetime

Thus you will need to add breakpoint and check values of all columns returned from database