views:

115

answers:

2

The MemberShipUser constructor expects dateTime fields like lastLoginDate, which may be null in the data store.

However, when I retrieve data from the store and pass null in for the parameter, I get an error that it cannot be null.

How can I work around this?

A: 

Update your query to return a date for nulls - maybe current date or '1900-01-01'

ISNULL(DateField, '1900-01-01') AS DateField
rvarcher
A: 

I believe the expectation with the ASP.NET standard Membership provider is that the user has registered on your site and as a result has effectively logged in at the same time as their user record was created.

If you are bulk loading the memberships then I'd suggest setting the lastLoginDate to DateTime.Now, better than leaving it null.

Lazarus
Can membership user be inherited with nullable DateTime fields for this instead? Or would such a subtle variation work?
Caveatrob