Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Using a parameter in a command Post Reply Post New Topic
Author Message
ve2yu
Newbie
Newbie
Avatar

Joined: 03 Nov 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote ve2yu Replybullet Topic: Using a parameter in a command
    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
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 03 Nov 2008 at 11:36am

Try this:

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

Joined: 03 Nov 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote ve2yu Replybullet 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
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 04 Nov 2008 at 10:01am

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

 
-Dell
IP IP Logged
ve2yu
Newbie
Newbie
Avatar

Joined: 03 Nov 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote ve2yu Replybullet Posted: 04 Nov 2008 at 11:04am
Thanks again
 
I get the same error
 
Clifford Sutton
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet 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
IP IP Logged
P_Borgke
Newbie
Newbie
Avatar

Joined: 28 Nov 2008
Location: Philippines
Online Status: Offline
Posts: 1
Quote P_Borgke Replybullet Posted: 01 Dec 2008 at 10:12pm
hey 
Most Wanted
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.