Click here to Skip to main content
14,361,948 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello To All,

I have a Crystal report in which i use Add command with 2 parameters.

1. for Database
2. For Days ( Selection Criteria)

now, when i run the report there is a selection parameter to select the company. and enter the number of days.

when user select the company, in behind i want to set that company database into add command by some parameter.

so, how can i achieve this ?

e.g :

select company : 1.AAA 2. BBB 3. CCC
AAA have database name"one","second" and "third" respectively.

i use the command like below:
SELECT     stocklederview.itname AS itemname, SUM(stocklederview.qtyin) AS qtyin, SUM(stocklederview.qtyout) AS qtyout, SUM(stocklederview.qtyin)- SUM(stocklederview.qtyout) as qty, stocklederview.unit AS unit, MAX(stocklederview.docdt) AS maxdt, itmast.material,
itgroup.dtldesc, gdmast.gdname
FROM        {?db}.dbo. stocklederview INNER JOIN
                      itmast ON stocklederview.itcode = itmast.itcode INNER JOIN
                      itgroup ON itmast.itgroup = itgroup.code INNER JOIN
                      gdmast ON stocklederview.gdcode = gdmast.gdcode
GROUP BY stocklederview.itname, stocklederview.unit, itmast.material, itgroup.dtldesc, gdmast.gdname
HAVING      SUM(stocklederview.qtyin)- SUM(stocklederview.qtyout) > 0 and (MAX(stocklederview.DOCdt) <= DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE() - {?DAYS})))
ORDER BY stocklederview.itname

here is two parameter, so when user select AAA then in this command "one"database must set in place of "{?db}".

please help me....
Updated 11-Oct-12 9:16am

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100