當我執行下面的存儲過程,我得到這個錯誤:事務計數後EXECUTE指示BEGIN和COMMIT語句的不匹配數
System.Data.SqlClient.SqlException: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
代碼:
create procedure [dbo].[sp_crm_diler_master]
(
@Fullname varchar(100),
@Email varchar(50),
@Mobile varchar(12),
@qualification varchar(50),
@presentaddress varchar(250),
@permanentaddress varchar(250),
@location varchar(50),
@skills varchar(100),
@Dob varchar(15),
@myphoto varbinary(Max),
@uniqueid varchar(25),
@Message varchar(150) output
)
AS
BEGIN
if not exists (select emailid,phone from crm_masterdata where [email protected] And [email protected])
begin
begin transaction
declare @small smalldatetime = (select CAST(@Dob as smalldatetime))
declare @todaydate datetime=(select getdate())
insert into crm_masterdata(uniqueid,fullname,phone,dob,photo,emailid,qualification,location,present_address,permanent_address,skillsets,datasource,entrydate,active)
values(@uniqueid,@Fullname,@Mobile,@small,@myphoto,@Email,@qualification,@location,@presentaddress,@permanentaddress,@skills,'reception',@todaydate,1)
Set @Message=' Registration Successfull,Please Login'
end
else
begin
set @Message='This User Already Registered'
end
end
哪裏是我的錯誤?
您的C#和asp.net代碼不相關。你的問題很嚴重在你的SP上。 – Claudio
我已刪除問題的不相關部分 –
您是否閱讀過錯誤?你是否在代碼中搜索提交語句? –