根据asp页面的位置在sql server中插入数据 [英] Insert data in sql server according to position from asp page

查看:109
本文介绍了根据asp页面的位置在sql server中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用sql server表来存储数据

有一个文件上传控件和一个用户文本框

在fileupload中他会选择文件和位置文本框中他将进入位置,该位置将存储在名为position的列中

我想检查用户是否正在上传文件并插入已存在某个文件的位置...如果是这样我想将所有位置增加1,大于位置

你可以建议代码

谢谢

Hi I am using sql server table to store data
There is an file upload control and one text box for user
In fileupload he will choose file and in position text box he will enter position, and that position will be stored in column named 'position'
I want to check if user is uploading file and inserting into position on which some file already exist... if so I want to increase all positions by 1 which is larger than than position
can u suggest code
thanks

推荐答案

你只需编写一个存储过程并检查并更新sp中的那个。您可以使用业务逻辑/服务层执行相同的操作



you just write a stored procedure and check and update that in side that sp. You may use Business logic/service layer to do the same thing

create proc UpdateFilePosition
(
   @FileName varchar(10)
   ,@ProposedPosition int
)
AS
begin
  if exitsts(select * from MyPositionsTable WHERE FileName = @FileName AND Position = @ProposedPosition)
  begin
       UPDATE MyPositionsTable SET Position += 1 WHERE   FileName = @FileName AND Position >= @ProposedPosition;       
  end
  insert MyPositionsTable(FileName, Position) values (@FileName, @ProposedPosition); 

end





存储过程检查提供的文件名和位置是否存在于表中,如果找到则将所有位置从建议位置开始增加1。这样,建议的位置将是唯一的。



Stored procedure check the provided file name and position is exists in table or not if found then it increase all positions by 1 started from proposed position. That way the proposed position will be unique.


这篇关于根据asp页面的位置在sql server中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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