Crystal Report unbound fields

  • Thread starter Thread starter Stephan
  • Start date Start date
S

Stephan

Hi,

I'm using Visual Studio 2003 (C#) with the integrated
Crystal Report software and have the following question:

How can I assign a value (string) to an unbound (string)
field in Crystal Report at runtime?

Example:
private void button1_Click(object sender,
System.EventArgs e)
{
DiskFileDestinationOptions Options = new
DiskFileDestinationOptions();
Options.DiskFileName = @"c:\test.pdf";
CrystalReport1 rep = new CrystalReport1();

//insert code to assign "my text" to the unbound
field "UnboundString1"???

rep.ExportOptions.ExportFormatType =
ExportFormatType.PortableDocFormat;
rep.ExportOptions.ExportDestinationType =
ExportDestinationType.DiskFile;
rep.ExportOptions.DestinationOptions = Options;
rep.Export();
}

Any help is appreciated
Many thanks
Stephan
 
Hello Ries,

From your description, we could see that the issue should be known before,
since there was a patch for it. I suggest you post your question at
http://www.crystaldecisions.com/. Though it ships with Visual Studio,
Crystal Reports is supported by Crystal Decisions. We have no source code
of it. They have a self-help section and they offer phone & e-mail support.
Their web sites states that you get two Crystal incidents with the purchase
of Visual Studio .NET.

Thanks very much for your understanding.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Ries Spruit" <[email protected]>
!Sender: "Ries Spruit" <[email protected]>
!References: <[email protected]>
<[email protected]>
!Subject: RE: Crystal Report unbound fields
!Date: Fri, 5 Sep 2003 02:58:59 -0700
!Lines: 192
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNzlFOG867Yx6kdQy+OAHqlPakujw==
!Newsgroups: microsoft.public.dotnet.general
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107406
!NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
!X-Tomcat-NG: microsoft.public.dotnet.general
!
!Hello Yanhong,
!
!In the context of this thread I'd like to know if you or
!anyone else has been able to assign a string containing
!newline characters to an unbound field. My experience is
!that \n and \t characters are completely ignored by the
!Crystal Reports engine.
!
!I want to show a lengthy string on a report. First I
!tried this using a report parameter but then I run into a
!bug (ADAPT00138140
!http://support.crystaldecisions.com/library/kbase/articles
!/c2010907.asp) for which a patch seems to be available,
!but NOT for OEM products.. I cannot get this installed
!with Visual Studion 2003 / .Net 1.1. The bug does not
!allow you to use String parameters longer then 255
!characters.
!
!So next I tried the way of the unbound field. But now
!newlines are ignored, so this is not working either.
!Somehow Crystal Reports seems very reluctant to work for
!me :-(
!
!Eagerly awaiting your reponse,
!
!Kind regards,
!Ries Spruit
!
!
!
!
!
!>-----Original Message-----
!>Hello Stephan,
!>
!>The following is a short code snippet to give you an
!idea of what we have had to do to pass data to Unbound
!Fields. Please
!>note that the process below is not dynamic and is just
!work in progress to better learn how to make the
!reporting process
!>work. Some other things to note are the fact that the
!name of the Unbound Fields (on the report) and the
!Formula Field
!>Definitions (in code) are the same. This is simply to
!avoid confusion on my part. When an Unbound Field is
!created, it is
!>listed under Formula Fields. There is no good way to
!tell one from another. Suffice to say that if a field is
!listed under Formula
!>Fields and it appears on the report, it is in fact an
!Unbound Field.
!>
!>public ReportViewerForm(string reportName)
!>{
!>//
!>// Required for Windows Form Designer support
!>//
!>InitializeComponent();
!>//
!>// TODO: Add any constructor code after
!InitializeComponent call
!>//
!>//formulas that will contain the field name
!>FormulaFieldDefinition DailyTellerTotalsReport;
!>FormulaFieldDefinition TransactionSummary;
!>FormulaFieldDefinition lblBank;
!>FormulaFieldDefinition valBank;
!>//Instantiate a Crystal Reports ReportDocument as
!myReport
!>CrystalDecisions.CrystalReports.Engine.ReportDocument
!myReport = new
!>CrystalDecisions.CrystalReports.Engine.ReportDocument();
!>//Load the needed report into myReport ?reportName is
!the path and name
!>//of the form to be used
!>myReport.Load(reportName);
!>//Set up Unbound Field definitions
!>FormulaFieldDefinitions crFormulas;
!>crFormulas = myReport.DataDefinition.FormulaFields;
!>//set the unbound fields
!>DailyTellerTotalsReport = crFormulas
!["DailyTellerTotalsReport"];
!>TransactionSummary = crFormulas["TransactionSummary"];
!>lblBank = crFormulas["lblBank"];
!>valBank = crFormulas["valBank"];
!>//Assign values ?Again, please note that the variable
!that have been defined
!>//have THE SAME NAME as the Unbound Fields on the report.
!>DailyTellerTotalsReport.Text = "\"Daily Teller Totals
!Report\"";
!>TransactionSummary.Text = "\"TransactionSummary\"";
!>lblBank.Text = "\"Bank\"";
!>valBank.Text = "\"Jamisonville\"";
!>//Set the viewer's report source to myReport
!>crViewer.ReportSource = myReport;
!>//Show the report maximized
!>this.WindowState = FormWindowState.Maximized;
!>}
!>
!>Besides, Crystal Reports for VS.NET will not allow you
!to add a database to a report at runtime. The report
!needs to have a
!>data structure in order for it to work. The report can
!connect to any datasource including a .NET dataset. For
!dynamic
!>reports, you can add a number of formula fields on the
!report and at runtime you can populate those formula
!fields and tell
!>them which database fields to display. We have a sample
!on this:
!><http://support.crystaldecisions.com/communityCS/FilesAnd
!Updates/vbnet_win_dynamic_report_formula.exe.asp>
!>
!>It's in vb.net but the code is the same for C# as well.
!>
!>If you need to be able to dynamically create a report
!from scratch at runtime, you will need access to our RAS
!object model.
!>RAS 9 comes with Crystal Reports 9. The object model
!that will allow you to do this is in Crystal Reports 9
!Advanced version.
!>
!>Hope that helps.
!>
!>Best regards,
!>Yanhong Huang
!>Microsoft Online Partner Support
!>
!>Get Secure! - www.microsoft.com/security
!>This posting is provided "AS IS" with no warranties, and
!confers no rights.
!>
!>--------------------
!>!Content-Class: urn:content-classes:message
!>!From: "Stephan" <[email protected]>
!>!Sender: "Stephan" <[email protected]>
!>!Subject: Crystal Report unbound fields
!>!Date: Fri, 15 Aug 2003 14:23:30 -0700
!>!Lines: 31
!>!Message-ID: <[email protected]>
!>!MIME-Version: 1.0
!>!Content-Type: text/plain;
!>! charset="iso-8859-1"
!>!Content-Transfer-Encoding: 7bit
!>!X-Newsreader: Microsoft CDO for Windows 2000
!>!Thread-Index: AcNjc3k5m8FXrjRnQJiX5hiqLCkiEw==
!>!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!>!Newsgroups: microsoft.public.dotnet.general
!>!Path: cpmsftngxa06.phx.gbl
!>!Xref: cpmsftngxa06.phx.gbl
!microsoft.public.dotnet.general:104727
!>!NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!>!X-Tomcat-NG: microsoft.public.dotnet.general
!>!
!>!Hi,
!>!
!>!I'm using Visual Studio 2003 (C#) with the integrated
!>!Crystal Report software and have the following question:
!>!
!>!How can I assign a value (string) to an unbound
!(string)
!>!field in Crystal Report at runtime?
!>!
!>!Example:
!>!private void button1_Click(object sender,
!>!System.EventArgs e)
!>!{
!>! DiskFileDestinationOptions Options = new
!>!DiskFileDestinationOptions();
!>! Options.DiskFileName = @"c:\test.pdf";
!>! CrystalReport1 rep = new CrystalReport1();
!>!
!>! //insert code to assign "my text" to the unbound
!>!field "UnboundString1"???
!>!
!>! rep.ExportOptions.ExportFormatType =
!>!ExportFormatType.PortableDocFormat;
!>! rep.ExportOptions.ExportDestinationType =
!>!ExportDestinationType.DiskFile;
!>! rep.ExportOptions.DestinationOptions = Options;
!>! rep.Export();
!>!}
!>!
!>!Any help is appreciated
!>!Many thanks
!>!Stephan
!>!
!>
!>
!>.
!>
!
 
Back
Top