ASP.NET Membership with two providers cant use GetAllUsers method
Posted
by Bayonian
on Stack Overflow
See other posts from Stack Overflow
or by Bayonian
Published on 2010-02-23T14:30:44Z
Indexed on
2010/03/09
8:21 UTC
Read the original article
Hit count: 762
Hi,
I'm using two membership providers. When I declared a following statement
Dim allUsers As MembershipUserCollection = Membership.Providers("CustomSqlRoleManager").GetAllUsers
Then, it gave me this error message.
Argument not specified for paramenter 'totalRecords' of 'Public MustOverride Function GetAllUsers(pageIndex as Integer, pageSize as Integer, ByRef totalRecords as Integer) As System.Web.Security.MembershipUserCollection'
Then, I added what it asked for like this :
Dim allUsers As MembershipUserCollection = Membership.Providers("CustomSqlRoleManager").GetAllUsers(1, 50, 100)
I don't get anything in return. I debugged it and allUsers = Nothing.
What's wrong the declaration above?
Do I really have to provider the paramenters when calling Membership.Providers("CustomSqlRoleManager").GetAllUsers?
Update 1
If, I used the statement below:
Dim allUsers As MembershipUserCollection = Membership.Providers("MembershipRoleManager").GetAllUsers(0, 0, totalUser)
I got this error message:
The pageSize must be greater than zero.
Parameter name: pageSize.
[ArgumentException: The pageSize must be greater than zero.
Parameter name: pageSize]
System.Web.Security.SqlMembershipProvider.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords) +1848357
But it works if I provied the pageSize param:
Dim pageSize As Integer = GetTotalNumberOfUser()
Dim allUsers As MembershipUserCollection = Membership.Providers("MembershipRoleManager").GetAllUsers(0, pageSize, totalUser)
This statment Dim pageSize As Integer = GetTotalNumberOfUser() returns the total counted record, it's already round trip to database, just to get the total number of users, because I need to provide the pageSize param value.
© Stack Overflow or respective owner