Page 1 of 1

Whats wrong with UserDataSource.LoadForCriteria?

Posted: Mon Mar 01, 2010 3:37 pm
by William_firefold
Im trying to make a report that lists all users that registered in a given time period.
When I use the UserDataSource.LoadForCriteria method to get the users, it just takes forever and then times out.
Im trying it like this:

Code: Select all

UserCollection users=UserDataSource.LoadForCriteria("CreateDate > ' "+fromDate.ToString("M/d/y")+" ' AND CreateDate < ' "+toDate.ToString("M/d/y")+" ' ");
foreach (User _user in users){	
Is the method not made for this purpose? Is there another way to do it?
We have 1100 users in the db.

Re: Whats wrong with UserDataSource.LoadForCriteria?

Posted: Tue Mar 02, 2010 7:21 am
by mazhar
Give a try by changing the code as below. Instead of manipulating the date format to trim the time part better set the time part to minimum possible on from date and maximum possible on to date so that time span covers all dates falling within criteria having any time part.

Code: Select all

DateTime fromDate = new DateTime(fromDate.Year,fromDate.Month,fromDate.Day,0,0,0);
DateTime toDate = new DateTime(toDate.Year,toDate.Month,toDate.Day,23,59,59);
UserCollection users=UserDataSource.LoadForCriteria("CreateDate >= ' "+fromDate.ToString()+"' AND CreateDate <= '"+toDate.ToString()+"'");

Re: Whats wrong with UserDataSource.LoadForCriteria?

Posted: Tue Mar 02, 2010 10:11 am
by William_firefold
thanks mazhar. I found out that the problem i was having is that apparently, the users database keeps record of users who arent registered too(or something). once I filtered down to those who have a non-null email, it went much faster.

Any idea why the users table is getting a new entry ~every 5 seconds and the entries dont have emails attached to them?
I thought the users table was only for registered users.