本文介绍了在VB中执行时存储过程获取错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi我的存储过程从VB执行时出错执行后的事务计数表示Begin和Commit状态不匹配,previouse count = 0,current count = 1,
我尝试过:
Hi My Stored procedure is getting errors when executing from VB " Transaction count after Execute indicates a mismatching of Begin and Commit statments, previouse count =0, current count =1,
What I have tried:
ALTER PROCEDURE [dbo].[SMlineUpdate3]
(
@id [int],
@Payroll_Id [int],
@ProductCode nvarchar(255),
@Description nvarchar (255),
@Qty nvarchar(255)
)
AS
IF EXISTS(SELECT Id from Smline where @id = Id)
DECLARE @User INT
BEGIN TRANSACTION
Update dbo.SmLine
Set [Payroll_Id]= @Payroll_Id
,ProductCode= @ProductCode
,Description = @Description
,Qty = @Qty
Where [Id]=@Id
IF @@ERROR <> 0
BEGIN
ROLLBACK
RETURN
END
ELSE
BEGIN TRANSACTION
DECLARE @SId INT
INSERT INTO SmLine ([Payroll_Id],[ProductCode],[Description],[Qty]) VALUES (@Payroll_Id,@ProductCode ,@Description,@Qty)
SET @SId= SCOPE_IDENTITY()
IF @@ERROR <> 0
BEGIN
ROLLBACK
RETURN
END
COMMIT
推荐答案
这篇关于在VB中执行时存储过程获取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!