siva balan

siva balan

  • NA
  • 92
  • 8.9k

Store procedure issue

Sep 29 2016 9:24 AM
I have error in my store procedure execution time.....
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1
My store procedure is
 
ALTER procedure [State](
@stid varchar(15),
@stname varchar(50),
@crdate date,
@Action varchar(15)
)
as
begin
SET NOCOUNT ON
SET XACT_ABORT ON
begin try
begin transaction
if(@Action='INS')
begin
insert into tblState(StId,State,CreatedDate) values (@stid,@stname,@crdate)
end
else if(@Action='ALL')
begin
select * from tblState
end
else if(@Action='UPD')
begin
update tblState set State=@stname where StId=@stid
end
else if(@Action='DEL')
begin
Delete from tblState where StId=@stid
end
else if(@Action='sel')
begin
select * from tblState where StId=@stid
end
else if(@Action='val')
begin
select State from tblState where State=@stname
end
commit
end try
begin catch
IF @@TRANCOUNT > 0
ROLLBACK
end catch
end
Please help me guys..... I am struggle in this error 

Answers (5)