Does anyone know what are the pageindex/pagesize for? in designing customer profile provider>>???[:(]
Private Function GetProfileInfo( _
ByVal authenticationOption As ProfileAuthenticationOption, _
ByVal usernameToMatch As String, _
ByVal userInactiveSinceDate As Object, _
ByVal pageIndex As Integer, _ByVal pageSize As Integer, _
ByRef totalRecords As Integer _
) As ProfileInfoCollection
Dim _sqlConnection As SqlConnection = New SqlConnection(_connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Profiles_Sel", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Connection = _sqlConnection
Dim _transaction As SqlTransaction = Nothing
' If searching for a user name to match add the command text and parameters.
If Not usernameToMatch Is Nothing Then
_sqlCommand.Parameters.Add("userName", SqlDbType.DateTime, 0).Value = usernameToMatch
End If
' If searching for inactive profiles add the command text and parameters.
If Not userInactiveSinceDate Is Nothing Then
_sqlCommand.Parameters.Add("inactivityDate", SqlDbType.DateTime, 0).Value = userInactiveSinceDate
End If
' If searching for a anonymous or authenticated profiles, add the command text
' and parameters.
If (authenticationOption = ProfileAuthenticationOption.Anonymous) Then
_sqlCommand.Parameters.Add("isAnonymous", SqlDbType.Bit, 0).Value = 1
Else
_sqlCommand.Parameters.Add("isAnonymous", SqlDbType.Bit, 0).Value = 0
End If
Dim _reader As SqlDataReader = Nothing
Dim _profiles As ProfileInfoCollection = New ProfileInfoCollection()
' Count profiles only.
If pageSize = 0 Then Return _profiles
Dim _counter As Integer = 0
Try
_sqlConnection.Open()
_reader = _sqlCommand.ExecuteReader(CommandBehavior.CloseConnection)
Dim _startIndex As Integer = pageSize * (pageIndex - 1)
Dim _endIndex As Integer = _startIndex + pageSize - 1
Do While _reader.Read()
If _counter >= _startIndex Then
Dim _profileInfo As ProfileInfo = New ProfileInfo( _
CType(_reader("UserName"), String), _
CType(_reader("IsAnonymous"), Boolean), _
CType(_reader("LastActivity"), DateTime), _
CType(_reader("LastUpdated"), DateTime), _
0 _
)
_profiles.Add(_profileInfo)
End If
If _counter >= _endIndex Then
End If
Then _sqlCommand.Cancel()
_counter += 1
Loop
Catch e As SqlException
Throw New Exception(e.Message)
Finally
_sqlConnection.Close()
End Try
totalRecords = _counter
Return _profiles
End Function
caijinjing
Member
44 Points
174 Posts
pageindex/pagesize in customer profile provider
Feb 13, 2008 03:48 PM|LINK
Does anyone know what are the pageindex/pagesize for? in designing customer profile provider>>???[:(]
Private Function GetProfileInfo( _ ByVal authenticationOption As ProfileAuthenticationOption, _ ByVal usernameToMatch As String, _ ByVal userInactiveSinceDate As Object, _ ByVal pageIndex As Integer, _ ByVal pageSize As Integer, _ ByRef totalRecords As Integer _ ) As ProfileInfoCollection Dim _sqlConnection As SqlConnection = New SqlConnection(_connectionString) Dim _sqlCommand As SqlCommand = New SqlCommand("Profiles_Sel", _sqlConnection) _sqlCommand.CommandType = CommandType.StoredProcedure _sqlCommand.Connection = _sqlConnection Dim _transaction As SqlTransaction = Nothing ' If searching for a user name to match add the command text and parameters. If Not usernameToMatch Is Nothing Then _sqlCommand.Parameters.Add("userName", SqlDbType.DateTime, 0).Value = usernameToMatch End If ' If searching for inactive profiles add the command text and parameters. If Not userInactiveSinceDate Is Nothing Then _sqlCommand.Parameters.Add("inactivityDate", SqlDbType.DateTime, 0).Value = userInactiveSinceDate End If ' If searching for a anonymous or authenticated profiles, add the command text ' and parameters. If (authenticationOption = ProfileAuthenticationOption.Anonymous) Then _sqlCommand.Parameters.Add("isAnonymous", SqlDbType.Bit, 0).Value = 1 Else _sqlCommand.Parameters.Add("isAnonymous", SqlDbType.Bit, 0).Value = 0 End If Dim _reader As SqlDataReader = Nothing Dim _profiles As ProfileInfoCollection = New ProfileInfoCollection() ' Count profiles only. If pageSize = 0 Then Return _profiles Dim _counter As Integer = 0 Try _sqlConnection.Open() _reader = _sqlCommand.ExecuteReader(CommandBehavior.CloseConnection) Dim _startIndex As Integer = pageSize * (pageIndex - 1) Dim _endIndex As Integer = _startIndex + pageSize - 1 Do While _reader.Read() If _counter >= _startIndex Then Dim _profileInfo As ProfileInfo = New ProfileInfo( _ CType(_reader("UserName"), String), _ CType(_reader("IsAnonymous"), Boolean), _ CType(_reader("LastActivity"), DateTime), _ CType(_reader("LastUpdated"), DateTime), _ 0 _ ) _profiles.Add(_profileInfo) End If If _counter >= _endIndex Then End If Then _sqlCommand.Cancel() _counter += 1 Loop Catch e As SqlException Throw New Exception(e.Message) Finally _sqlConnection.Close() End Try totalRecords = _counter Return _profiles End Function-----------------------------------------------------------------------------------------------------------------------
Thanks a lot