如果电源故障或用户错误地关闭页面,则删除插入一半的数据表行,如果完整字段有数据,则仅更新数据表 [英] Delete the half inserted datatable rows if a power failure or user closes page by mistake, updated only the datatable if the full field has data

查看:79
本文介绍了如果电源故障或用户错误地关闭页面,则删除插入一半的数据表行,如果完整字段有数据,则仅更新数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含10个字段的DataTable,其中5个字段将从一个界面获取数据插入,其余五个字段将从另一个界面获得更新 ...问题是如果出现电源故障或用户错误地关闭了第二个接口,前五个字段将被插入,但接下来的五个字段将不会更新,因为当我们再次加载页面时,交易号将会改变.....是否有任何方法可以删除前五行,除非我们更新了所有十个字段........它很难理解...请尝试理解这一点并帮助我

I have a DataTable with ten fields and five of the fields will get data inserted from one interface and the rest five fields will get updated from another interface....The problem is if there is a power failure or the user closes the second interface by mistake the first five fields gets inserted but the next five will not get updated as when we load the page again the transaction number will change.....Is there any method that we can delete the first five rows unless we have updated the all ten fields........Its difficult to understand...please try to understand this and help me out

推荐答案

引用:

您是否在同一个表中插入了存储过程?您可以使用有助于您解决问题的交易。

Are you inserting into the same table do you have any Stored procedure ? You can use transactions which will help you to resolve your issue.










CREATE PROCEDURE usp_TransactionTest @Value int, @RollBack bit
AS 
BEGIN
	BEGIN TRANSACTION
	INSERT INTO tb_TransactionTest VALUES (@Value)
	IF @Rollback = 1 
		-- If the procedure is called from within a transaction
		-- this is going to cause us to have a different 
		-- @@TRANCOUNT when we exit the procedure than when we
		-- started it.
		ROLLBACK TRANSACTION
	ELSE
		COMMIT
END
GO





问候,

Praveen Nelge



Regards,
Praveen Nelge


这篇关于如果电源故障或用户错误地关闭页面,则删除插入一半的数据表行,如果完整字段有数据,则仅更新数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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