public class Customer 
{ 
public String CustomerID { get; set; } 
public String CompanyName { get; set; } 
public String ContactName { get;set;} 
public String ContactTitle { get; set; } 
public String Address { get; set; } 
public String City { get; set; } 
} 
SearchCustomerByName 存储过程的代码如下: 
SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO 
Create PROCEDURE SearchCustomerByName 
@name nvarchar(30), 
@pageIndex int, 
@pageSize int 
AS 
BEGIN 
SET NOCOUNT ON; 
select t.CustomerID,t.CompanyName,t.ContactName,t.ContactTitle,t.Address,t.City from 
( 
select Row_Number() over (order by CustomerID) AS RowNum,* from Customers where ContactName like '%'+@name+'%' 
) t 
where t.RowNum between @pageIndex*10+1 and (@pageIndex+1)*10 
select count(*) from Customers 
where ContactName like '%'+@name+'%' 
END 
GO 
具体的效果,大家可以把上述的代码响应的复制到VS中和数据库中,进行演示。
这个版本其实很多的功能点都是没有考虑到的,仅仅是个示例,大家可以在自己的实际项目中修改以上的功能来满足自己的需求。
您可能感兴趣的文章:
