I am trying to page through a portion of the data in a table and therefore I
think I need to use Custom Paging.
... but, I am wondering if I can pass a dataset that was obtained through a
function that returns a dataset that is a portion of a table. Apparently I
cannot do this as I keep getting the CurrentPageIndex must be or = 0 and <
PageCount error.
I guess I do not fully understand Custom Paging yet, so I will do some
reading on it but it seems that my method should work. My only thought is
that the PageCount is based on ALL of the records in a table and not just the
subset of records returned from my function. Also, I have found that
PageCount is readonly.
Here is the code I am using:
Function GetRecords(ByVal record As Integer) As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole
DB Services=-4; Data Source=C:\path\accessfile.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT [tablename].* FROM [tablename] WHERE
([discussion].[record] = @dotnet.itags.org.anotherrecord)"
Dim dbCommand As System.Data.IDbCommand = New Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_record As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_record.ParameterName = "@dotnet.itags.org.record"
dbParam_record.Value = record
dbParam_record.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_record)
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New
System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Sub BindData(sortExpr as String)
Dim dataSet As DataSet = New DataSet()
dataSet = GetRecord(recordID)
'Finally, specify the DataSource and call DataBind()
DataGrid1.DataSource = dataset
DataGrid1.DataBind()
End Sub
Any feedback is appreciated.
- GlennPaging in Dataset assumes that the dataset contains complete set of data.
-Augustin
"glenn" wrote:
Quote:
Originally Posted by
Hi folks,
>
I am trying to page through a portion of the data in a table and therefore I
think I need to use Custom Paging.
>
... but, I am wondering if I can pass a dataset that was obtained through a
function that returns a dataset that is a portion of a table. Apparently I
cannot do this as I keep getting the CurrentPageIndex must be or = 0 and <
PageCount error.
>
I guess I do not fully understand Custom Paging yet, so I will do some
reading on it but it seems that my method should work. My only thought is
that the PageCount is based on ALL of the records in a table and not just the
subset of records returned from my function. Also, I have found that
PageCount is readonly.
>
Here is the code I am using:
>
Function GetRecords(ByVal record As Integer) As System.Data.DataSet
>
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole
DB Services=-4; Data Source=C:\path\accessfile.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )
>
Dim queryString As String = "SELECT [tablename].* FROM [tablename] WHERE
([discussion].[record] = @.anotherrecord)"
Dim dbCommand As System.Data.IDbCommand = New Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
>
Dim dbParam_record As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_record.ParameterName = "@.record"
dbParam_record.Value = record
dbParam_record.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_record)
>
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New
System.Data.DataSet
dataAdapter.Fill(dataSet)
>
Return dataSet
End Function
>
>
Sub BindData(sortExpr as String)
>
Dim dataSet As DataSet = New DataSet()
>
dataSet = GetRecord(recordID)
>
'Finally, specify the DataSource and call DataBind()
DataGrid1.DataSource = dataset
DataGrid1.DataBind()
>
End Sub
>
>
>
Any feedback is appreciated.
- Glenn
0 comments:
Post a Comment