Sql Server 编写分页存储过程
2016-03-26 21:34
555 查看
一、Sql 存储过程中的编写及执行
二、程序中调用存储过程
效果图:
--创建存储过程 create proc BookInfo @pageSize int, @pageIndex int as select top(@pageSize) * from dbo.Books where BNO not in( select top(@pageSize*(@pageIndex-1)) BNO from dbo.Books )--这里只使用了单表查询,最常使用的是多表链接查询 --使用情况 exec BookInfo 5,5
二、程序中调用存储过程
string sqlConnection = "Data Source=.;Initial Catalog=LibrarySyatem;Integrated Security=True"; SqlConnection connection = new SqlConnection(sqlConnection); SqlCommand command = new SqlCommand("BookInfo", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@pageIndex", 5)); command.Parameters.Add(new SqlParameter("@pageSize", 5)); SqlDataAdapter ad = new SqlDataAdapter(command); DataSet ds = new DataSet(); ad.Fill(ds); this.GridView1.DataSource = ds; this.GridView1.DataBind();
效果图:
相关文章推荐
- 在Mac电脑上安装MySql
- mysql 索引和Lucene索引
- oracle学习-用户被锁
- MySQL存储引擎--Memory
- Redis JAVA API的用法例子
- [C#基础]c#连接mysql
- 【机房个人重构】sqlHelper------让我们的代码更高效
- SQL Server Configuration Manager.msc在哪
- SQL基础知识(1)
- MySQL存储引擎--MyISAM
- 数据库基础学习-了解DBMS
- mysql优化小方法
- MySQL存储引擎--InnoDB
- oracle终端基本命令
- 内存数据库
- SqlDateTime 溢出。
- [022]Redis使用教程
- Mysql,Oracle,Java数据类型对应
- 数据库表格数据导出到excel方法总结
- 只读事务的理解