我正在使用两个会员提供商。当我声明以下声明时
Dim allUsers As MembershipUserCollection = Membership.Providers("MembershipRoleManager").GetAllUsers
然后,它给了我这个错误信息。
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'
然后,我添加了它要求的内容:
Dim allUsers As MembershipUserCollection = Membership.Providers("MembershipRoleManager").GetAllUsers(1, 50, 100)
我没有得到任何回报。我调试了它,allUsers = Nothing。
上面的声明有什么问题?
调用 Membership.Providers("MembershipRoleManager").GetAllUsers 时我真的必须提供参数吗?
更新 1
如果,我使用以下语句:
Dim allUsers As MembershipUserCollection = Membership.Providers("MembershipRoleManager").GetAllUsers(0, 0, totalUser)
我收到此错误消息:
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
但如果我提供了 pageSize 参数,它就可以工作:
Dim pageSize As Integer = GetTotalNumberOfUser()
Dim allUsers As MembershipUserCollection = Membership.Providers("MembershipRoleManager").GetAllUsers(0, pageSize, totalUser)
这条语句 Dim pageSize As Integer = GetTotalNumberOfUser() 返回总计数记录,它已经往返数据库,只是为了获取用户总数,因为我需要提供 pageSize 参数值。