H
Hari
Hi,
Iam working with a custom grid control to navigate
navigate large number of records from a table.
The control need to have row up, row down, page up, page
down features.
Requirements are :
page size = 30 records
maximum records in database table - 20,000 (each record
150K)
I was looking the msdn samplePaging through a query
result) its shows building dynamic query for every pages.
So inorder to this way, if i want to navigate a singe row
( up/down (one record) do i need to build a query every
time? or is there any better way to approach this??
please help me guys......
Hari
The sample i was looking :
case "Next":
selCmd.CommandText = "SELECT TOP " + pageSize + "
CustomerID, CompanyName FROM Customers " +
"WHERE CustomerID > @CustomerId
ORDER BY CustomerID";
selCmd.Parameters.Add("@CustomerId",
SqlDbType.VarChar, 5).Value = lastVisibleCustomer;
break;
case "Previous":
selCmd.CommandText = "SELECT TOP " + pageSize + "
CustomerID, CompanyName FROM Customers " +
"WHERE CustomerID < @CustomerId
ORDER BY CustomerID DESC";
selCmd.Parameters.Add("@CustomerId",
SqlDbType.VarChar, 5).Value = firstVisibleCustomer;
break;
default:
selCmd.CommandText = "SELECT TOP " + pageSize + "
CustomerID, CompanyName FROM Customers ORDER BY
CustomerID";
// Determine total pages.
SqlCommand totCMD = new SqlCommand("SELECT Count
(*) FROM Customers", nwindConn);
nwindConn.Open();
int totalRecords = (int)totCMD.ExecuteScalar();
nwindConn.Close();
totalPages = (int)Math.Ceiling((double)
totalRecords / pageSize);
break;
Iam working with a custom grid control to navigate
navigate large number of records from a table.
The control need to have row up, row down, page up, page
down features.
Requirements are :
page size = 30 records
maximum records in database table - 20,000 (each record
150K)
I was looking the msdn samplePaging through a query
result) its shows building dynamic query for every pages.
So inorder to this way, if i want to navigate a singe row
( up/down (one record) do i need to build a query every
time? or is there any better way to approach this??
please help me guys......
Hari
The sample i was looking :
case "Next":
selCmd.CommandText = "SELECT TOP " + pageSize + "
CustomerID, CompanyName FROM Customers " +
"WHERE CustomerID > @CustomerId
ORDER BY CustomerID";
selCmd.Parameters.Add("@CustomerId",
SqlDbType.VarChar, 5).Value = lastVisibleCustomer;
break;
case "Previous":
selCmd.CommandText = "SELECT TOP " + pageSize + "
CustomerID, CompanyName FROM Customers " +
"WHERE CustomerID < @CustomerId
ORDER BY CustomerID DESC";
selCmd.Parameters.Add("@CustomerId",
SqlDbType.VarChar, 5).Value = firstVisibleCustomer;
break;
default:
selCmd.CommandText = "SELECT TOP " + pageSize + "
CustomerID, CompanyName FROM Customers ORDER BY
CustomerID";
// Determine total pages.
SqlCommand totCMD = new SqlCommand("SELECT Count
(*) FROM Customers", nwindConn);
nwindConn.Open();
int totalRecords = (int)totCMD.ExecuteScalar();
nwindConn.Close();
totalPages = (int)Math.Ceiling((double)
totalRecords / pageSize);
break;