Solved

How do I use a multivalue parameter on SQL Server command window in Crystal Reports 2008?

Posted on 2011-09-13
5
243 Views
Last Modified: 2012-06-27
Hello,

I'm using a SQL command window in Crystal 2008 as the data source for my report. I've checked the box in the command parameter window to "allow multiple values" but I'm getting an error message when I use mulitple parameters.

Below is a simplified version of my sql code:

declare @Company as varchar(4);
set @Company = {?Company}   ----  {?Company} is the multivalue parameter

select c.company_id, c.description, c.ownership_pct
from company c
where c.company_id = {?Company}


Do I need to change the syntax of my query when using the "allow muliple values" feature? I've tried changing the code to "where c.company_id in {?Company}" but I continue to get the attached error message.

Any ideas on how to get past this error?

Thanks!
David
 Crystal Reports Error Message
0
Comment
Question by:dking_wri
  • 2
  • 2
5 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 400 total points
ID: 36530857
The multiple values is for parameters you build through the ADD PARAMETER button in the command window.  It is not for parameters you declare in that way.

Why are you using the SET, that is declaring a parameter in the command.  Try deleting that line

mlmcc
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 100 total points
ID: 36530908
I would use IN rather than =
0
 

Author Comment

by:dking_wri
ID: 36531844
Hi mlmcc,

I'm using SET as I have repeated the variable multiple times in the actual code. But I think I'm following your question. Maybe I should replace every instance of the @company with the Crystal equivalent  {?Company}. Let me try that and I'll get back to you.

Hi peter57r,

I did use the IN function when I first encountered the error. I'll try this again in combination with mlmcc comment and get back to you.

Thanks again,
David
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36532351
You declared @Company s a VARCHAR(4), it can't have multiple values.

mlmcc
0
 

Author Closing Comment

by:dking_wri
ID: 36532382
Thanks for the help. I replaced my declared SQL variable with the Crystal Parameter and it worked.

I used the IN statement again, but this time I removed the parenthesis and was able to get the report to run as expected.

Thanks again for your time and input!!

David
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question