事件触发时行上的工作操作 [英] working operations on rows on event fire

查看:101
本文介绍了事件触发时行上的工作操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的asp.net页上有一个网格,网格上有一个删除链接,通过该链接我从网格中删除一行,从而使数据库具有网格的rowdelete事件,并使用一个ID作为唯一列,并以此列为基础.现在,这个独特的列就像uq00001/1及其varchar.我希望当我从网格中删除一行时,例如网格有5行,而我正在删除第三行,因此在数据库中,唯一ID就像uq0001/1,uq0002/2,uq0003/3.网格,然后将行从数据库中删除,并将其他ID填充后的其他ID.例如.当删除第三行时,第4行将变为uq0003,第5行将变为uq004 ..同样明智的做法是,在网格中添加行时也必须增加.但是删除是我被困在的地方.
我想通过数据库做到这一点.我曾尝试在存储过程中使用游标,但无法正常工作.

I have a a grid on my asp.net page and grid has a delete link by which i delete a row from grid so as database with rowdelete event of grid using one id as uniquecolumn and rows on the basis of this column. now this unique colum is like uq00001/1 and its varchar. i want that when i delete one row from grid for example grid has 5 rows and i am deleting 3rd row so in database the unique id ll be like uq0001/1,uq0002/2,uq0003/3.. nowif i delete third row from grid then the row ll ve deleted from database and the other ids after these ll be adgested. eg. when thrid row is deleted then the 4rth row ll become uq0003 and 5th ll become uq004.. like wise i have to do to increment also when add row in grid. but deletion is where i am stucked in .
and i want to do this through database. i have tried cursor inside a stored procedure but its not working.

推荐答案

declare @repid varchar(20)
declare @rows int
set @repid=(select distinct receiptid from tempdepositslipdtls where custreceiptno='')
set @rows=(select count(custreceiptno)from tempdepositslipdtls where receiptid=@repid)

declare @f varchar(30)
declare @g int
set @f=@repid
set @g=convert(int,(select (substring(custreceiptno,12,4)-1)from tempdepositslipdtls where custreceiptno=''))




declare @counter int
set @counter=0
  while(@counter<=@rows)
    begin
     update tempdepositslipdtls
        set custreceiptno=@f+@g
        where custreceiptno=@custreceiptno;
set @counter=@counter +1

..now here receiptid is the id which has three more uniqueid ie custreceiptno
for example  
ReceiptID - custreceiptno/1
            custreceiptno/2
            custreceiptno/3
this  code was without cursor.. and  have one more code with cursor that is also not working but i want to code without cursor.


这篇关于事件触发时行上的工作操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆