SELECT语句上的sql rowlock

编程入门 行业动态 更新时间:2024-10-28 04:30:00
本文介绍了SELECT语句上的sql rowlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个ASP.Net网页,用户可以在其中选择要编辑的行.我想在该行上使用行锁,并且当用户完成编辑并更新后,另一位用户可以编辑该行,即如何使用行锁,以便只有一个用户可以编辑行?

I have an ASP.Net webpage where the user selects a row for editing. I want to use the row lock on that row and once the user finishes the editing and updates another user can edit that row i.e. How can I use rowlock so that only one user can edit a row?

谢谢

推荐答案

您无法使用数据库引擎锁来锁定像这样的行.

You can't lock a row like that using DB engine locks.

大多数其他策略将依靠保持连接打开(例如sp_getapplock),这在Web应用程序中是荒谬的.

Most other strategies would rely on keeping the connection open (such as sp_getapplock) and this is nonsensical in web apps.

即使您在该行上设置了一个标志,如果用户只是简单地在编辑过程中关闭浏览器,会发生什么?

Even if you set a flag on the row, what happens if the user simply closes the browser mid-edit?

我建议使用时间戳/行版本列来检测其他会话中对该行的更改.

I'd suggest using a timestamp/rowversion column to detect changes to the row in other sessions.

更多推荐

SELECT语句上的sql rowlock

本文发布于:2023-07-22 03:47:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1183867.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语句   SELECT   rowlock   sql

发布评论

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

>www.elefans.com

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