我有一个表,如下:
自动ID 名字 年龄 序列号(排序用的)
1001 df 21 1
1002 df1 22 2
1003 df2 23 3
1004 df3 25 4
1005 df4 26 5
1006 df4 27 6
1007 df5 28 7
1008 df6 29 8
1009 df7 20 9
我有两个按钮,一个向下移动,一个向上移动
例如我选重1005这一行,点向下移动,1005这行的序列号5就+1;1006这行的序列号就-1;而1005这行就
移动到1006这行的下面,
而改变的序列号要保存到数据,下次查看时保持移动后的效果
最最好给我点码参考,谢谢大哥哥了拉,因为我是新手,所以我做拉两天,就是达不到这样效果,谢谢拉,在线等
自动ID 名字 年龄 序列号(排序用的)
1001 df 21 1
1002 df1 22 2
1003 df2 23 3
1004 df3 25 4
1005 df4 26 5
1006 df4 27 6
1007 df5 28 7
1008 df6 29 8
1009 df7 20 9
我有两个按钮,一个向下移动,一个向上移动
例如我选重1005这一行,点向下移动,1005这行的序列号5就+1;1006这行的序列号就-1;而1005这行就
移动到1006这行的下面,
而改变的序列号要保存到数据,下次查看时保持移动后的效果
最最好给我点码参考,谢谢大哥哥了拉,因为我是新手,所以我做拉两天,就是达不到这样效果,谢谢拉,在线等
-- Add the parameters for the stored procedure here
@id as int
AS
BEGIN
declare @anotherID int
--这个是向下移动,向上移动类似
select * from test1 where test1.id=@id
update test1 set sortID=sortID-1 where test1.id=(select top 1 test1.id from test1 where test1.id>@id)
update test1 set sortID=sortID+1 where test1.id=@id
SET NOCOUNT ON; -- Insert statements for procedure here
END
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
[age] [int] NOT NULL,
[sortID] [int] NOT NULL
) ON [PRIMARY]