Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 13th, 2004, 05:01 AM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crystal Report on the Fly with C#

Hi all!

I've read i can Customize Report Fields at Run Time.
I've tried creating a blank report with 3 formula fields (@Formula1, @Formula2, @Formula3)

In my c# code i created a DataSet and filled it with data taken from an SQL Server, a simple list of clients (fields: id, name, text1).

Now, how can i use my blank report to assign Formula1 to id, Formula2 to name, etc...

I've tried with:

DtaClienti = new SqlDataAdapter( );
DstClienti = new DataSet( );
CmdClienti = new SqlCommand( );
CmdClienti.Connection = CnnClienti;
CmdClienti.CommandType = CommmandType.Text
CmdClienti.CommandText = "SELECT 'id','name','text1' FROM [01_clienti]";
DtaClienti.SelectCommand = CmdClienti;
DtaClienti.Fill (DstClienti,"clienti");

CrystalReport1 myReport = new CrystalReport1();

myReport.Load();
myReport.SetDataSource(DstClienti);

FormulaFieldDefinitions myFormulas;
FormulaFieldDefinition FormulaField1;
FormulaFieldDefinition FormulaField2;
FormulaFieldDefinition FormulaField3;

myFormulas = myReport.DataDefinition.FormulaFields;

FormulaField1 = myFormulas[0];
FormulaField2 = myFormulas[1];
FormulaField3 = myFormulas[2];

FormulaField1.Text = "{clienti.id}";
FormulaField2.Text = "{clienti.name}";
FormulaField3.Text = "{clienti.text1}";

crViewer.ReportSource = myReport;


But an error occurs telling me that {clienti.id} is not a valid key!
It seems that the report hasn't loaded the dataset correctly. Any Idea???:(





Similar Threads
Thread Thread Starter Forum Replies Last Post
simple report and crystal report in vb.net saket123 .NET Framework 2.0 0 August 13th, 2008 06:55 AM
Crystal Report sumith ASP.NET 2.0 Basics 2 September 27th, 2007 10:45 PM
VS 2002 Crystal Report opens Seagate crystal 8 tusis_1 Crystal Reports 0 May 12th, 2007 11:45 AM
Crystal Report sravs BOOK: Professional Crystal Reports for VS.NET 0 December 29th, 2004 04:51 AM
Error While printing report (Crystal report) vikaspaweb Pro VB 6 0 March 8th, 2004 09:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.