Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,
I have a webform from where I am generating reports from different options like getting reports by department wise, date wise or by item name wise. I am generating crystal report with stored procedure. But when I select any option from drop-downs(like if I have selected computer deptt.) the crystal report have to show data of computer deptt only) but it shows all deptt. data, same is like with other options. There is something error in stored procedure, but I am not getting that. How to get report of related options?

Htored procedure is here:


ALTER PROCEDURE Test
(
@id as int,
@itemid as int,
@date as datetime
)
As
begin
select it.Item_Allot_Date,it.Item_Allot_Id,it.Item_Allot_Desc,
it.Item_Alloted_Unit,dep.Dept_Name,st.Item_Id,
st.Store_Item_Name,st.Store_Item_Desc,
st.Store_Item_Unit,st.Store_Purchased_Unit,
st.Store_Item_Cost,st.Store_Item_TotalCost,
st.Stroe_Item_Remaining_Unit from sss_store_alloted_items as it 
left join sss_sub_dept_master as dep on it.Item_Allot_Dep_Id=dep.Dept_ID
left join sss_store_items as st on it.Item_Allot_Item_Id=st.Item_Id
end
Begin
          If (@id>0 and @itemid=0)
              Begin
                       select it.Item_Allot_Date,it.Item_Allot_Id,it.Item_Allot_Desc,
it.Item_Alloted_Unit,dep.Dept_Name,st.Item_Id,
st.Store_Item_Name,st.Store_Item_Desc,
st.Store_Item_Unit,st.Store_Purchased_Unit,
st.Store_Item_Cost,st.Store_Item_TotalCost,
st.Stroe_Item_Remaining_Unit from sss_store_alloted_items as it 
left join sss_sub_dept_master as dep on it.Item_Allot_Dep_Id=dep.Dept_ID
left join sss_store_items as st on it.Item_Allot_Item_Id=st.Item_Id
where it.Item_Allot_Dep_Id=@id 
             End
         Else if(@id>0 and @itemid>0)
              Begin
                        select it.Item_Allot_Date,it.Item_Allot_Id,it.Item_Allot_Desc,
it.Item_Alloted_Unit,dep.Dept_Name,st.Item_Id,
st.Store_Item_Name,st.Store_Item_Desc,
st.Store_Item_Unit,st.Store_Purchased_Unit,
st.Store_Item_Cost,st.Store_Item_TotalCost,
st.Stroe_Item_Remaining_Unit from sss_store_alloted_items as it 
left join sss_sub_dept_master as dep on it.Item_Allot_Dep_Id=dep.Dept_ID
left join sss_store_items as st on it.Item_Allot_Item_Id=st.Item_Id
where it.Item_Allot_Dep_Id=@id or st.Item_Id=@itemid 
              End
              else
              if(@id>0 and @itemid>0 and @date>0)
              begin
              select it.Item_Allot_Date,it.Item_Allot_Id,it.Item_Allot_Desc,
it.Item_Alloted_Unit,dep.Dept_Name,st.Item_Id,
st.Store_Item_Name,st.Store_Item_Desc,
st.Store_Item_Unit,st.Store_Purchased_Unit,
st.Store_Item_Cost,st.Store_Item_TotalCost,
st.Stroe_Item_Remaining_Unit from sss_store_alloted_items as it 
left join sss_sub_dept_master as dep on it.Item_Allot_Dep_Id=dep.Dept_ID
left join sss_store_items as st on it.Item_Allot_Item_Id=st.Item_Id
where it.Item_Allot_Dep_Id=@id or st.Item_Id=@itemid or it.Item_Allot_Date=@date

              end
              
end
return



Only at a time I am passing one parameter and I am putting zero values to other parametres in front end.
Posted
Updated 18-Aug-10 1:10am
v2

1 solution

Dear amit

The first output from database is used in Crystal Report.

begin
select it.Item_Allot_Date,it.Item_Allot_Id,it.Item_Allot_Desc,
it.Item_Alloted_Unit,dep.Dept_Name,st.Item_Id,
st.Store_Item_Name,st.Store_Item_Desc,
st.Store_Item_Unit,st.Store_Purchased_Unit,
st.Store_Item_Cost,st.Store_Item_TotalCost,
st.Stroe_Item_Remaining_Unit from sss_store_alloted_items as it 
left join sss_sub_dept_master as dep on it.Item_Allot_Dep_Id=dep.Dept_ID
left join sss_store_items as st on it.Item_Allot_Item_Id=st.Item_Id
end

the above code returns all the values hence, the crystal report shows up all the values

Ensure that, the required output is only returned from the SQL Procedure
 
Share this answer
 

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