3

I am getting this error when I retrieve a row with a null DataTime field:

'srRow.Closed_Date' threw an exception of type 'System.Data.StrongTypingException'

How do I properly handle these?

Mike Wills
  • 20,959
  • 28
  • 93
  • 149
  • How are you pulling down the information? Is it in a data table or a strong typed object? – Aaron Jul 30 '09 at 16:26

3 Answers3

6

You can check for a null value in that column before retrieving the value.

if (!srRow.IsClosed_DateNull())
{
  myDate = srRow.Closed_Date;
}
Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
1

There's a reference here.

or possibly, can you modify your query to ensure the results are not null by using the IsNull operator?

Select (IsNull, SomeDateField, GetDate())
David
  • 72,686
  • 18
  • 132
  • 173
0

Assuming you're using .NET, there are SqlTypes that can be used in a situation like this.

Tyler
  • 514
  • 2
  • 9