Whats wrong with UserDataSource.LoadForCriteria?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Whats wrong with UserDataSource.LoadForCriteria?

Post by William_firefold » Mon Mar 01, 2010 3:37 pm

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.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Whats wrong with UserDataSource.LoadForCriteria?

Post by mazhar » Tue Mar 02, 2010 7:21 am

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()+"'");

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Whats wrong with UserDataSource.LoadForCriteria?

Post by William_firefold » Tue Mar 02, 2010 10:11 am

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.

Post Reply