Newbie - Passing list of parameters
Hi,
I have this query in the crystal report
SELECT tblEmployees.iEmployeeNum, tblEmployees.tLastName, tblEmployees.tFirstName
FROM tblEmployees
WHERE tblEmployees.iEmployeeNum IN ({?empNum})
?empNum is parameter define to allow multiple values (numbers)
When I create this, a form is shown to enter values (probably to test this query).
If I enter one value for ?empNum, everything is fine, but if I try to enter 2 or more integers there is error saying
---
Failed to retrive data from the database.
Details: ADO Error Code: 0x
Source: Microsoft OLE DB Provider for SQL Server
Discription: Incorrect syntax near ','
SQL State 42000
Native Error: [Database Vendor Code: 102]
---
Please help. Thanks.
Re: Newbie - Passing list of parameters
Quote:
?empNum is parameter define to allow multiple values (numbers)
Try a range definition
Quote:
When I create this, a form is shown to enter values (probably to test this query).
That's a normal operation in Crystal Reports to enter parameters values
JG
Re: Newbie - Passing list of parameters
ok I solved this. I created function SplitArrayIDs that returns me table with those param int values and to the function i send string for example "1,2,3,4,5"
and in the select i add
JOIN dbo.SplitArrayIDs(@listId) AS s ON dbo.tblEmployees.iEmployeeNum = s.ArrayID
The "WHERE tblEmployees.iEmployeeNum IN ({?empNum})" i don't need it
works fine