rollback問題

orcale 2003-09-17 09:53:08
我用asp.net操作sql server的時候,不能正常rollback.後來我thow出錯誤,錯誤號295,重要性16.
請各位說說sql server應該如何設定,才能正常rollback
請大家也談談transcation如何工作的,是不實警告的級別高了之後,不能rollback?
...全文
37 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
txlicenhe 2003-09-17
  • 打赏
  • 举报
回复
应该可以,是不是你在前面已经有提交。
txlicenhe 2003-09-17
  • 打赏
  • 举报
回复
应该可以,是不是你在前面已经有提交。
txlicenhe 2003-09-17
  • 打赏
  • 举报
回复
应该可以,是不是你在前面已经有提交。
happydreamer 2003-09-17
  • 打赏
  • 举报
回复


把你的代码贴出来看看

帮助里的例子 参考一下
用 @@ERROR 检测几条语句的成功
下面的示例取决于 INSERT 和 DELETE 语句的成功操作。局部变量在两条语句后均被设置为 @@ERROR 的值,并且用于此操作的共享错误处理例程中。

USE pubs
GO
DECLARE @del_error int, @ins_error int
-- Start a transaction.
BEGIN TRAN

-- Execute the DELETE statement.
DELETE authors
WHERE au_id = '409-56-7088'

-- Set a variable to the error value for
-- the DELETE statement.
SELECT @del_error = @@ERROR

-- Execute the INSERT statement.
INSERT authors
VALUES('409-56-7008', 'Bennet', 'Abraham', '415 658-9932',
'6223 Bateman St.', 'Berkeley', 'CA', '94705', 1)
-- Set a variable to the error value for
-- the INSERT statement.
SELECT @ins_error = @@ERROR

-- Test the error values.
IF @del_error = 0 AND @ins_error = 0
BEGIN
-- Success. Commit the transaction.
PRINT "The author information has been replaced"
COMMIT TRAN
END
ELSE
BEGIN
-- An error occurred. Indicate which operation(s) failed
-- and roll back the transaction.
IF @del_error <> 0
PRINT "An error occurred during execution of the DELETE
statement."

IF @ins_error <> 0
PRINT "An error occurred during execution of the INSERT
statement."

ROLLBACK TRAN
END
GO

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧