Mapping clients from a SQL Server database using data catalog management in asp.net

I have a list of 1000 clients that I show through a datalist control in asp.net. The list displays one client per page.

The query I use to link the data list is:

static public DataTable GetAllCustomers()
{
    string sql = "Select * from [Customers]";
    SqlDataAdapter da = new SqlDataAdapter(sql, ConnectionString);
    DataTable dt = new DataTable();
    da.Fill(dt);
    return dt;
}

What I want to do is when the client is browsing, he must return to the bottom of the list so that after the user is logged in a second time, he does not need to start from the very beginning of viewing the same client, clients must go to the bottom of the list of 1000 clients, for example, if one client 1 is viewed, then the next time when client 1 becomes 1000 clients and client 2 becomes client 1, hope that this makes sense.

, db .

+5
3

, ,

+1

. , ,

ALTER TABLE YourTableName 
ADD NewColumnName DATETIME DEFAULT getdate()

, . , GetDate()

, . , ...

static public DataTable GetAllCustomers()
{
    string sql = "Select * from [Customers]";
    using (SqlDataAdapter da = new SqlDataAdapter(sql, ConnectionString))
    {
        using (DataTable dt = new DataTable())
        {
            da.Fill(dt);
            return dt;
        }
    }
}

, ...

+1

- , CustomterID, .

, LastCustomerID → CuLast Max rows → CuMax, SQL .

WITH CustomersNewOrder as (
 select *, CustomerID-CuLast as OrderMe from Customers where CustomerID > CuLast
union
 select *, CustomerID+CuMax as OrderMe from Customers where CustomerID <= CuLast 
) select * from CustomersNewOrder order by OrderMe

When the CuLast > CuMax then make the CuLast = 0

, , , 0, , , .

, , , .

Because you say that you won to be the same for all users, and I believe that you have only one pool, then a static value anywhere in the global space can do the job that saves the last show.

+1
source

All Articles