Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: How to reference an outer .NET class or .DLL Post Reply Post New Topic
Author Message
losingsleeep
Newbie
Newbie
Avatar

Joined: 27 Sep 2009
Location: United Kingdom
Online Status: Offline
Posts: 12
Quote losingsleeep Replybullet Topic: How to reference an outer .NET class or .DLL
    Posted: 27 Sep 2009 at 1:59am
Hi All.
I'm using crystal report in visual studio 2008 (Visual C#).
could any body tell me how to use .NET classes or .DLLs from crystal report .rpt file?
for example i wanna convert my Date valued columns to PersianDate.
(the PersianDate convertor methods and objects are stored in my visual studio project)
 
tnx.


Edited by losingsleeep - 27 Sep 2009 at 2:03am
thanks, Bobby.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 27 Sep 2009 at 10:03am

You can't access the functions in your application from a report.  You have to create a UFL (user function library) that contains them in order for Crystal to be able to read them.

For more info about how to create UFL's, go here: http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm and search for "Overview of User-Defined Functions".
 
-Dell
IP IP Logged
losingsleeep
Newbie
Newbie
Avatar

Joined: 27 Sep 2009
Location: United Kingdom
Online Status: Offline
Posts: 12
Quote losingsleeep Replybullet Posted: 27 Sep 2009 at 10:20pm
Hi hilfy.
thanks for your help and time spending.
I searched it and found how to create an ActiveX assembly that CrystalReport can see it, just some hours before you reply me.
please accept my thanks and take a look at me further times.
thanks, Bobby.
IP IP Logged
losingsleeep
Newbie
Newbie
Avatar

Joined: 27 Sep 2009
Location: United Kingdom
Online Status: Offline
Posts: 12
Quote losingsleeep Replybullet Posted: 27 Sep 2009 at 11:33pm
Hi again.
i have two questions:
 
Q No.1 :
 
I used some funcions in a co-library in my CRUFL .NET project. I mean i added a reference to a .DLL that helps me to process something (eg. complex algorithms & functions & ...). So, how can i be able to use it in Crystal Report? at runtime it shows an error : "Not enough memory for operation". it seems that the error is not about Memory , it's because CrystalReport can't understand what i used and applied in my assembly. what should i do?
 
Q No.2 :
 
How can i prevent prompting for parameters in passing parameters to crystal report via C#.NET 2008?
i tried some ways and solutions friends said, but always the prompt window appears. realy what's the problem?
 
thanks, Bobby.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 29 Sep 2009 at 7:07am
I don't really have an answer for your first question.
 
For your second, can you post the code you use to set the parameters?  When you get the parameter screen, do the params show the values that you set?
 
-Dell
IP IP Logged
losingsleeep
Newbie
Newbie
Avatar

Joined: 27 Sep 2009
Location: United Kingdom
Online Status: Offline
Posts: 12
Quote losingsleeep Replybullet Posted: 29 Sep 2009 at 7:19am
Hi hilfy.
it's my code:
----------------------
rptDoc.SetParameterValue("RP_Title", "It is the Title");
rptViewer.RefreshReport();
--------------------
'rptDoc' is the Crystal Report report file.
'rptViewer' is the Report Viewer.
....
it is memorable that if i remove the 'rptViewer.RefreshReport()' , the prompt no longer appears. but if the user clicks Refresh button of report viewer at runtime , it appears again. (finally , i removed the button too!)
and i must say : when the prompt appears, doesn't have my value at its textbox.
thanks bro.
thanks, Bobby.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 29 Sep 2009 at 8:24am
Ok, you're setting the parameter in the Report file, but not in the report in the viewer.  Once you set the ReportSource in the viewer, the report there is a different object than the report document - changing one will NOT change the other.  I'm assuming that rptDoc is a ReportDocument object.
 
A couple of rules for setting parameters in reports from code so that the viewer doesn't show the parameter screen:
 
1.  Don't set values for subreport links (parameter name starts with "Pm").
2.  You must set some sort of value for ALL other parameters - even if there is a default value declared for the parameter.
 
In our web application, here's the code we use to set parameters:
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();
ParameterValues curvalues = new ParameterValues();
foreach (ParameterFieldDefinition parafld in crReport.DataDefinition.ParameterFields)
{
  //Get the value of the param from the QueryString for the viewer page
  discreteVal.Value = Request.QueryString[parafld.ParameterFieldName];
  //There is no param with this name in the QueryString so set default val
  if (discreteVal.Value == null)
  {
    if(parafld.ParameterFieldName.Substring(0,2) != "Pm")
    {
      switch (parafld.ValueType.ToString())
      {
        case "NumberField":
            discreteVal.Value = 1;
            break;
        case "StringField":
            discreteVal.Value = "A";
            break;
        case "DateField":
            discreteVal.Value = "01/01/1990";
            break;
        case "CurrencyField":
            discreteVal.Value = "0";
            break;
        case "Int32sField":
            discreteVal.Value = "0";
            break;
    }
    curvalues.Add(discreteVal);
    parafld.ApplyCurrentValues(curvalues);
  }
  //there is a value for this param, so set it.
  else if (discreteVal.Value != null)
  {
    curvalues.Add(discreteVal);
    parafld.ApplyCurrentValues(curvalues);
  }
}
 
We then set the ConnectionInfo for the tables and only after all of that is complete do we set the ReportSource for the viewer.
 
-Dell 


Edited by hilfy - 29 Sep 2009 at 8:25am
IP IP Logged
losingsleeep
Newbie
Newbie
Avatar

Joined: 27 Sep 2009
Location: United Kingdom
Online Status: Offline
Posts: 12
Quote losingsleeep Replybullet Posted: 29 Sep 2009 at 10:32pm
Thank you so much Dell (hilfy).
I'll try it...
thanks, Bobby.
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.016 seconds.