Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameter into a Stored Procedure

Status
Not open for further replies.

gyfu

Programmer
May 28, 2001
77
HK
Hi All,
I have been reading many post about passing parameter values into a Stored Procedure but doesn't seem to find a way to do it.

Can someone please point me to the right direction?

I am looking into using a passing parameter values into a stored procedure.

My actual problem is this.

1) I have a report which has a date parameter and an accountid.

2) I have also created a subreport using a Stored Procedure. The stored procedure accepts a date parameter and an accountid as well.

I would like to link the parameter values from the main report into the SP via the sub report.

Is this possible?

Please advise. Thanks.

Crystal Report 2008
SQL Server 2005




-- gyfu --
Crystal Ver 10
Microsoft SQL
 
Try Edit > Subreport Links. Note that it will add a line to the subreport record selection. You can change or delete this if it's not what you want.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Hi Madawc,
I did that but somehow I cannot link the parameter field to the SP parameter. Somehow the date parameter in the SP doesn't show up in the link window.


not sure what i am doing wrong.

-- gyfu --
Crystal Ver 10
Microsoft SQL
 
Try creating a dummy field in the subreport that the parameter will link to.

Your problem is probably due to different data types, a date may be viewed as a string or a number. You can adjust this using ToText or ToDate.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Hi Madawc,
My problem is not with the field in the CR but rather the fields in the SP.

Let me give you the example...

Code:
CREATE PROCEDURE [rpt_SP]
(@BeginDate smalldatetime, @EndDate smalldatetime,@UserID int)  

AS

BEGIN

DECLARE @AmtPaid as money
DECLARE @AssignedBillBal as money




Select @AmtPaid = sum(amountpaid) from account
where Datetaken between @BeginDate and @EndDate
and employeeid = @UserID
and status in (1,2)

Select @AssignedBillBal = sum(billbalance) from UserHistory where 
employeeid = @UserID 
and snapshotdate between @BeginDate and @EndDate


Select @UserID as UserID, @AmtPaid as AmountPaid, @AssignedBillBal as AssignedAmount


END

in CR, the only field available for linking is the Userid, but the BeginDate and Enddate is not shown. Is it the data type that I am having it incorrectly?


Thanks



-- gyfu --
Crystal Ver 10
Microsoft SQL
 
This makes no sense to me. Can anyone else help?

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top