savitha
asked on
Passing null value to crystal report parameter from csharp
String.empty is passed to a string parameter in crystal report.When we check IsNull(stringparameter) in crystalreport formula it returns false.
rptDoc.SetParameterValue(1 ,string.Em pty);----c sharp
if IsNull({?String}) then "Empty parameter" else {?String}---crystal report formula field
rptDoc.SetParameterValue(1
if IsNull({?String}) then "Empty parameter" else {?String}---crystal report formula field
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the replies. The parameters for the crystal report is passed through two applications 1. using classic ASP , 2. using C# . In ASP , the string can be passed as "null" , but if i pass the string value as "null" in C# it show "Type mismatch" error The formula in the crystal report should not be changed bcoz the crystal reports will be designed by the client.
I'm confused about what you're asking...
You say the value is passed differently from two applications so I gave you the solution to handle this within Crystal. You then say you don't want to change the Crystal report so I'm not sure what solution you hope to find.
You can resolve this either by changing the report or by changing the way the values are passed in so they are consistent. If you are asking whether it is possible to pass a null value in with c#, the answer to that question is no, it is not possible.
The standard approach in this situation would be to pass an empty string consistently because all applications should be able to handle this and Crystal can check for an empty string (using the code I gave you not using the IsNull function).
frodoman
You say the value is passed differently from two applications so I gave you the solution to handle this within Crystal. You then say you don't want to change the Crystal report so I'm not sure what solution you hope to find.
You can resolve this either by changing the report or by changing the way the values are passed in so they are consistent. If you are asking whether it is possible to pass a null value in with c#, the answer to that question is no, it is not possible.
The standard approach in this situation would be to pass an empty string consistently because all applications should be able to handle this and Crystal can check for an empty string (using the code I gave you not using the IsNull function).
frodoman
ASKER
Thanks frodoman for your responce . As you mentioned i have changed the formula in crystal report.
Pass the parameter with out assigning a value to the object of ParameterDiscreteValue.
String.empty is not the same as null. It actually has a reference to an empty string (i.e. "") in it.
You should check for if(stringparameter.Equals(
hth