VB.NET help with dates

Soldato
Joined
1 Feb 2006
Posts
8,188
Hi,

I have the following code but am having problems using null dates as optional parameters in a function. See below...

Code:
Public Shared Function SendMail(Optional ByVal o As User = Nothing, Optional ByVal configid As Integer = Nothing, Optional ByVal dob As Nullable(Of DateTime) = Null, Optional ByVal email As String = Nothing) As User
   Return UserData.SendMail(o, configid, dob, email)
End Function

The error is with this part:

Code:
Optional ByVal dob As Nullable(Of DateTime) = Null

The error message displayed says 'Optional parameters cannot have structure types'. Any ideas what I need to do here? If no date parameter is passed I want to pass null or nothing.
 
Got sorted with this. VB.NET doesn't seem to get on with null dates at all so instead I had to use SqlTypes.SqlDateTime.MinValue. I could then ignore this value in my Stored Proc.
 
Back
Top Bottom