Replaced DateTime.Parse with DateTime.TryParse to avoid exceptions.
More secure check for connection