Print Page | Close Window

Using a parameter in a command

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4699
Printed Date: 01 May 2024 at 10:23pm


Topic: Using a parameter in a command
Posted By: ve2yu
Subject: Using a parameter in a command
Date Posted: 03 Nov 2008 at 7:25am
I have a report and bring over a parameter from a list box in .net. this works fine and the parameter prints on the header.
The parameter is {?Mycategory}
 
I have created a command  with the following statement and it works fine
 
select * from inventory where category = '{?Mycategory}'
 
what I want to do is to be able to use the report for two purposes.
1) if the user selects a categaory which is working
2) if the user wants a complete list
 
I assume the command would be the following
 
if '{?Mycategory}' = "Complete List" then
select * from inventory
else
select * from inventory where category = '{?Mycategory}'
end if
 
this does not work   what am I syntaxing wrong?
 
clifford sutton


-------------
Clifford Sutton



Replies:
Posted By: hilfy
Date Posted: 03 Nov 2008 at 11:36am

Try this:

Select * from inventory
where ({?Mycategory} = 'Complete List')
  or (category = {?MyCategory})
 
-Dell
 


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: ve2yu
Date Posted: 03 Nov 2008 at 11:54am
Thankyou I tried it and I get the following
 
Database Connector error 'DAO error code 0xc03
source: DAO
Description syntax error (Missing Operator) in query expression '(='Complete List') or (category=)'.'
 
 
cliff


-------------
Clifford Sutton


Posted By: hilfy
Date Posted: 04 Nov 2008 at 10:01am

Try putting single quotes around the second {?MyCategory}.

 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: ve2yu
Date Posted: 04 Nov 2008 at 11:04am
Thanks again
 
I get the same error
 


-------------
Clifford Sutton


Posted By: hilfy
Date Posted: 04 Nov 2008 at 2:43pm
Would you please post your whole SQL so that I can take a look at it?
 
Thanks!
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: P_Borgke
Date Posted: 01 Dec 2008 at 10:12pm
hey 

-------------
Most Wanted



Print Page | Close Window