Click here to Skip to main content
15,905,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can we bind a stored procedure with if else condition to crystal report
Stored procedure Shown below
[sp_report_select_paymentsettlemnt_details]

@settlementperiodcode nvarchar(15),@fromdate datetime ,@todate datetime,@condition nvarchar(2)
AS
BEGIN

if @condition=3
--paysettled
BEGIN
SELECT *
FROM dbo.view_paymentsettlemnt_details as t1
WHERE settlementperiodcode =@settlementperiodcode and tdate>=@fromdate and tdate<=@todate and paymentsettlementid<>''
ORDER BY acccode, itemcode;
END
else if @condition=2
BEGIN
SELECT *
FROM dbo.view_paymentsettlemnt_details as t1
WHERE settlementperiodcode =@settlementperiodcode and tdate>=@fromdate and tdate<=@todate and paymentsettlementid=''
ORDER BY acccode, itemcode;
END
else
--all
BEGIN
SELECT *
FROM dbo.view_paymentsettlemnt_details as t1
WHERE settlementperiodcode =@settlementperiodcode and tdate>=@fromdate and tdate<=@todate
ORDER BY acccode, itemcode ;
END

END

It always give same result
Posted

1 solution

When you check Nvarchar Always should be like this

if @condition='3'

may be this is your mistake in SP
 
Share this answer
 
v2
Comments
rajin kp 13-Jun-12 7:54am    
Iam check that but still get result for condition 2 only

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900