PC Review


Reply
Thread Tools Rate Thread

Creating a very simple report: Crystal Report and SetParameterValue ?

 
 
Rodo
Guest
Posts: n/a
 
      27th Apr 2007
Hi all,

I'm trying to generate a simple crystal report without a database. Several
people mention the use of a dataset. Someone mention in a msdn forum that I
could use the SetParameterValue to easily fill the fields in a simple
report. So. I looked at datasets and I think I'll try this way first. I'm
pretty new and I still don't understand much of this stuff. So. here is what
I did . and it is not working :-(.

1.-create new windows application: WindowsAppication1.

2.-from the toolbox I add a 'ReportDocument'. This brings up the 'Choose a
ReportDocument" window. There is only one choice in the dropdown box:
'Untyped ReportDocument'. Pressed OK. ReportDocument shows below the form.

3.-Project|add New Item| Crystal Report. CrystalReport1.rpt. This brings up
the 'type of report' window from crystal report. I choose blank report. Then
I add an "unbounded text" field to section 2 (page header) of the report
file. I figure I'll try this with only one field first.

4.-Back to the form[design]. Click on Data source and add a new source.
Options are: Database, web service, object. I picked
object|WindowsAppication1|CrystalReport1. Clicked on the finished button.

5.- I selected the DocumentReport1 icon below the form and change the 'Name'
property to the CrystalReport1 file I created in number 3 above.


The truth is, I don't know what to do in number 4. There are several
choices. I picked Form1 while trying and there isn't any effects I can see.
Now I'm thinking that everything went pretty well, no errors, no warnings !
(It compiles and runs ok). Of course, there is nothing in the form yet. I
added a button and try this:

reportDocument1.SetParameterValue("UnboundString1","abcde");

I get an exception telling me that the index is incorrect. Yeap, I have no
clue why. I guess 'UnboundString1' is not the name of the field. I think I'm
missing something :-( .. Or maybe is a whole bunch :-).

I like to be able to
(1) change the value in the text field I created in the .rpt file
(2) and later preview it
(3) and print it.

Could someone point me in the right direction for changing the field through
a button's on_click event. I'll deal with the other two issues later :-).

Thanks a bunch.


 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      27th Apr 2007
Hi,

I usually use Dataset to generate reports, I find it easier and more
configurable.

If you want to just generate a simple report you could use only parameters,
I have done this in the past to be able to print a nicely formatted page.

Basically you create your report as you mentioned. After that you add the
parameters you need.

Once the report has all the required parameters you go to code view and code
it like this:

ReportDocument rd = new MyReportName()
rd.SetParameterValue( "param1", value1);
....
rd.SetParameterValue( "paramN", valueN);

//finally assign the report to the viewer
crystalReportViewer1.ReportSource = rd;



"Rodo" <(E-Mail Removed)> wrote in message
news:kfgYh.4708$A72.2324@trnddc07...
> Hi all,
>
> I'm trying to generate a simple crystal report without a database. Several
> people mention the use of a dataset. Someone mention in a msdn forum that
> I could use the SetParameterValue to easily fill the fields in a simple
> report. So. I looked at datasets and I think I'll try this way first. I'm
> pretty new and I still don't understand much of this stuff. So. here is
> what I did . and it is not working :-(.
>
> 1.-create new windows application: WindowsAppication1.
>
> 2.-from the toolbox I add a 'ReportDocument'. This brings up the 'Choose a
> ReportDocument" window. There is only one choice in the dropdown box:
> 'Untyped ReportDocument'. Pressed OK. ReportDocument shows below the form.
>
> 3.-Project|add New Item| Crystal Report. CrystalReport1.rpt. This brings
> up the 'type of report' window from crystal report. I choose blank report.
> Then I add an "unbounded text" field to section 2 (page header) of the
> report file. I figure I'll try this with only one field first.
>
> 4.-Back to the form[design]. Click on Data source and add a new source.
> Options are: Database, web service, object. I picked
> object|WindowsAppication1|CrystalReport1. Clicked on the finished button.
>
> 5.- I selected the DocumentReport1 icon below the form and change the
> 'Name' property to the CrystalReport1 file I created in number 3 above.
>
>
> The truth is, I don't know what to do in number 4. There are several
> choices. I picked Form1 while trying and there isn't any effects I can
> see. Now I'm thinking that everything went pretty well, no errors, no
> warnings ! (It compiles and runs ok). Of course, there is nothing in the
> form yet. I added a button and try this:
>
> reportDocument1.SetParameterValue("UnboundString1","abcde");
>
> I get an exception telling me that the index is incorrect. Yeap, I have no
> clue why. I guess 'UnboundString1' is not the name of the field. I think
> I'm missing something :-( .. Or maybe is a whole bunch :-).
>
> I like to be able to
> (1) change the value in the text field I created in the .rpt file
> (2) and later preview it
> (3) and print it.
>
> Could someone point me in the right direction for changing the field
> through a button's on_click event. I'll deal with the other two issues
> later :-).
>
> Thanks a bunch.
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to run report creating by Crystal Report 9 zazie Microsoft Access Form Coding 0 30th Apr 2008 09:18 AM
Simple Report (Not a Crystal Report) halaor Microsoft C# .NET 1 17th Aug 2007 09:08 PM
Sending Crystal Report to Network Print Mailbox While Bypassing Crystal Report Viewer. John Smith Microsoft VB .NET 0 17th Jan 2007 04:17 PM
Crystal Report: SetParameterValue not doing what it says!!!!! Alex Stevens Microsoft Dot NET 2 7th Jul 2004 02:23 PM
Change Crystal Report Zoom Level using percentages in Crystal Report Viewer (Dotnet) Alex Stevens Microsoft Dot NET 1 30th Jun 2004 12:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:50 PM.