根据asp页面的位置在sql server中插入数据

编程入门 行业动态 更新时间:2024-10-26 20:27:16
本文介绍了根据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中插入数据

本文发布于:2023-10-12 17:35:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485401.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   页面   数据   asp   server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!