CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    2

    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.

  2. #2
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Newbie - Passing list of parameters

    ?empNum is parameter define to allow multiple values (numbers)
    Try a range definition
    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

  3. #3
    Join Date
    Mar 2010
    Posts
    2

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured