码迷,mamicode.com
首页 > Web开发 > 详细

普通MVC

时间:2018-07-29 22:33:04      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:mvc   数据集   key   int   exec   table   sele   bsp   添加   

create table lei
(
lid int identity ,
lname varchar(30)
)
create table biao
(
bid int primary key identity ,
bname varchar(30) ,
age varchar(30) ,
lid int
)
drop table biao

--显示---
create proc up_show
@tableName varchar(8000), --表名、视图名
@indexCol varchar(50) = ‘id‘, --标识列名(如:比如主键、标识,推荐使用索引列)
@pageSize int = 10, --页面大小
@pageIndex int = 0, --当前页
@orderCol varchar(100) = ‘id desc‘,--排序 (如:id)
@where varchar(max) = ‘‘, --条件
@columns varchar(500) = ‘*‘ --要显示的列
as
declare @sql varchar(max)
declare @sql2 varchar(max)
declare @where2 varchar(max)
if @where <> ‘‘
begin
select @where2 = ‘ And ‘ + @where
select @where = ‘ Where ‘ + @where
end
else
select @where2 = ‘‘
select @sql = ‘Select Top ‘ + Convert(varchar(10),@pageSize) + ‘ ‘ + @columns + ‘ From ‘ + @tableName
select @sql2 = @sql + @where
select @sql = @sql + ‘ Where ‘ + ‘(‘ + @indexCol + ‘ Not In (Select Top ‘ + Convert(varchar(10), @pageSize * @pageIndex) + ‘ ‘ + @indexCol + ‘ From ‘ + @tableName + @where + ‘ Order by ‘+ @orderCol +‘))‘
select @sql = @sql + @where2
select @sql = @sql + ‘ Order by ‘ + @orderCol
--获取数据集
exec (@sql)
PRINT @sql
select @sql2 = Replace(@sql2,‘Top ‘ + Convert(varchar(10), @pageSize) + ‘ ‘ + @columns, ‘count(1)‘)
--获取总数据条数
exec(@sql2)

 

--添加


create proc up_add
(
@bname varchar(30) ,
@age varchar(30) ,
@lid int
)
as
begin
insert into biao values(@bname,@age,@lid)
end

---修改--
create proc up_upt
(
@bid int ,
@bname varchar(30) ,
@age varchar(30) ,
@lid int
)
as
begin
update biao set bname=@bname,age=@age,lid=@lid where bid=@bid
end

----删除
create proc up_del
(
@bid int
)
as
delete from biao where bid=@bid

普通MVC

标签:mvc   数据集   key   int   exec   table   sele   bsp   添加   

原文地址:https://www.cnblogs.com/JXSBoKeYuan/p/9387661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!