473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Passing null value to Crystal Reports parameter

PK
Hi, I have an application that opens a Crystal report document and
passes in a value to a parameter in the report (pointing to an Oracle
DB). However, if I want to pass a "null" value to retrieve all records
that have no data for the specified field that the parameter is a
condition of (ie. SELECT * from <table> where <field> is null"), it
returns nothing. I think CR is building the SQL statement like "SELECT
* from <table> where <field> = null". If I put in a value, it retrieve
records properly. Other than creating a stored procedure to handle the
null value and build my own SQL to fetch the records (this would be
problematic for me because I want to be able to pass in multiple values
for a parameter), is there anything I can do?

Here is my code:

paramFieldDef = oRpt.DataDefinition.ParameterFields[0];
ParameterDiscreteValue discreteValue = new ParameterDiscreteValue();
ParameterValues curValues = paramFieldDef.CurrentValues;

discreteValue.Value = null;

curValues.Add(discreteValue);

Nov 17 '05 #1
2 19299
Try using this in your code:

discreteValue.Value = DBValue.Null;

instead and see if it will work.

"PK" <ko*****@hotmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Hi, I have an application that opens a Crystal report document and
passes in a value to a parameter in the report (pointing to an Oracle
DB). However, if I want to pass a "null" value to retrieve all records
that have no data for the specified field that the parameter is a
condition of (ie. SELECT * from <table> where <field> is null"), it
returns nothing. I think CR is building the SQL statement like "SELECT
* from <table> where <field> = null". If I put in a value, it retrieve
records properly. Other than creating a stored procedure to handle the
null value and build my own SQL to fetch the records (this would be
problematic for me because I want to be able to pass in multiple values
for a parameter), is there anything I can do?

Here is my code:

paramFieldDef = oRpt.DataDefinition.ParameterFields[0];
ParameterDiscreteValue discreteValue = new ParameterDiscreteValue();
ParameterValues curValues = paramFieldDef.CurrentValues;

discreteValue.Value = null;

curValues.Add(discreteValue);

Nov 17 '05 #2
PK
I have tried that, and I get this error when I try to assign it:

"Value does not fall within the expected range"

Now, this might get into something more Crystal specific, but I edited
the record selection formula in the report to the following:

if IsNull({?PARAMETER}) Then
(
// returns all records where TABLE.COLUMN_A is null OR
// TABLE.COLUMN_A matches the other parameter values
// in the array (if parameter accepts multiple values)

IsNull({TABLE.COLUMN_A}) OR
{TABLE.COLUMN_A} = {?PARAMETER}
)
else
(
// returns all records where TABLE.COLUMN_A matches
// the parameter values in the array (if parameter
// accepts multiple values)

{TABLE.COLUMN_A} = {?PARAMETER}
)
This works when I pass in only 1 null parameter, but if I pass in an
array of parameter values (ie. 1, 2, null, 4, 5), the report only
returns records that meet the parameter values that were set AFTER the
null value was inserted. In the example above where the parameter
values are "1, 2, null, 4, 5", the report only retrieves records that
match values 4 and 5, ignoring 1, 2, and null.

for (int k = 0; k < strReportValue.Length; k++)
{
// discrete value
ParameterDiscreteValue discreteValue = new
ParameterDiscreteValue();
if (strReportValue[k] == "")
discreteValue.Value = null;
else
discreteValue.Value = strReportValue[k];

curValues.Add(discreteValue);
}

paramFieldDef.ApplyCurrentValues(curValues);

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: cem marifet | last post by:
I am trying to pass in a value of null to a webservice parameter. I 've tried xsi:nil="true" attribute on the parameter tag. But it is not recognizing the value as null. Is there any thing else...
5
by: Jet | last post by:
Hi all, I had a code like the follow: class A{ ... public void get(int i,params OleDbParameter p) { if((p!=null)||(p.Length>0)) { // Do some work }
0
by: aky | last post by:
Hi Im performing Parameter Fields Runtime Customization for crystal reports through VS.NET 2003, using C# as code Behind the ParameterFieldName property (and the other properties such as...
3
by: Brian Henry | last post by:
How do you pass a null into a crystal reports parameter? I have been trying dbnull.value in vb.net and that does not work, just gives an error... thanks
1
by: David Shorthouse | last post by:
Hey folks, I am attempting to pass null as the input value from a series of textboxes if the user does not input a value prior to submit. To try and do this, I am using a vbscript function on...
6
by: Smish | last post by:
hey all, I am passing parameters through code to a stored procedure in both windows application (using c# and sql server & crystal reports)and web application(using asp.net & sql server & crystal...
0
by: paul | last post by:
Hello, I have recently upgraded to VB .net 2005 and a Crystal report that before did not use to prompt for its single parameter now does so. I have been writing the parameter value to the report...
0
by: minnug | last post by:
Newbie I would like to pass four variables from one asp page to another asp page showing crystal reports. The crystal report would be embedded in the second page. I can use the previous page...
3
by: Dan Aldean | last post by:
Hi, To create a Crystal Reports I use a ReportViewer. How can I pass parameters to the report which is based on a stored procedure. Please provide some code. Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.