473,545 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can someone please show me how to correct this Crystal Report code?

I am trying to write an application that allows me to dynamically load
selected Crystal Report files, read the parameters from the report file,
give the user a chance to enter relevant data in a user friendly manner and
then run the report in a report viewer.

I can find bits and pieces of the instructions for doing this, but I don't
seem to be able to put it all together. For now I have some code that will
show a file Open dialog and let me select the report file. The next step I
believe is to load that file into a Report document. Once the document is
loaded, then I should be able to access its parameterFieldI nfo. Here is
code I have cobbled together so far:
// I open the dialog by clicking a command button
private void button1_Click(o bject sender, System.EventArg s e)

{

// Displays an OpenFileDialog so the user can select a Cursor.

OpenFileDialog openFileDialog1 = new OpenFileDialog( );

openFileDialog1 .Filter = "Report Files (*.rpt)|*.rpt";

openFileDialog1 .Title = "Select a Report File";

// Show the Dialog.

// If the user clicked OK in the dialog and a .RPT file was selected, then
open it.

if (openFileDialog 1.ShowDialog() == DialogResult.OK )

{

// I thought the next line of code would load the file into the Report
Dcoument, but I get the error below.

//An unhandled exception of type 'System.NullRef erenceException ' occurred in
ReportManager.e xe

ReportDocument1 .Load(openFileD ialog1.FileName );

//I am not quite sure how to access the values in the parameter fields They
are part of the Crystal Report Engine DataDefinition object, and so is the
Report document, but I don't understand the link..

for( int i =0 ;i< dataDef1.Parame terFields.Count ;i++)

{

listBox1.Items. Add(dataDef1.Pa rameterFields.C urrent.ToString ());

dataDef1.Parame terFields.MoveN ext();

}

}

}
Nov 16 '05 #1
2 2047
Hi
look at this sample in this link that describes How to create a Dynamic
report using C#. I would say this could be all what you need to know
<http://support.crystaldecisions.com/...es/csharp_win_
dynamic_report_ formula.exe.asp >
If you are using The Microsoft SQL server Database these also are very good
samples

<http://support.crystaldecisions.com/...es/csharp_web_
simplelogonview er.exe.asp>
<http://support.crystaldecisions.com/...es/csharp_win_
dbengine.exe.as p>
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC

Nov 17 '05 #2
Please, when you post code to newsgroups, try to make it as complete as
possible.

Somewhere in your code you declare:

ReportDocument ReportDocument1 .

apparently you are missing the following:

ReportDocument1 = new ReportDocument( );

(I can't really tell because you didn't post the declaration.) After
you've done this, then you can say:

ReportDocument1 .Load(openFileD *ialog1.FileNam e);

and it should work.

As for the parameter definitions, you should be able to say:

foreach (ParameterField Definition parm in
ReportDocument1 .DataDefinition .ParameterField s)
{
listBox1.Items. Add(parm.Name);
// ...or do whatever you like with the parameter here...
}

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2016
by: Mustafa Haider | last post by:
HI, I have created a report in Crystal Reports 8.5 and want to display it on my clients webpage. I will develop this webpage in ASP v3 so plz give me the code with which to show this report of Crystal Reports 8.5 in the webpage developed in ASP v 3 . I used Crystal Report Viewer ActiveX control but I do not know what code to write so that the...
2
13422
by: Sam | last post by:
Hello everyone, I have a table, which contains a picture column, I put URL info into it. "www.myweb.com/1.jpg..." I want to show this picture in my crystal report, I find some samples show the "static" picture in Crystal report, No "Dynamic" one. Can Crystal Report do that? Thanks in advance. Sam
1
7749
by: Richard Golebiowski | last post by:
I have been trying to figure this out for quite some time and cannot find any examples in VB.Net or in VB that work correctly. I am working on an application where I want the user to be able to select a peinter and printer tray to print reports out. In Crystal Reports 8.5, I can select a printer and tray and it prints correctly. I did a test...
0
1357
by: Tarek | last post by:
hi all, I just created a new crystal report with pie chart. But when I started to test, then it cannot show the pie chart, it shows "x" on the chart top-left corner. but just only show the correct data. WHY?? I feel appreciated that anyone can help me .... ^^' ... -- Regards,
8
4332
by: Rod | last post by:
I've written a Visual Studio .NET application (WinForms app) and put a Crystal Reports for .NET report in it. It is a very simple application - one regular form and another with the crystal reports viewer on it. When I run the application on my development machine, I can see the report just fine. However, when I install the application...
1
12147
by: Karthic | last post by:
When i right click on the .rpt file in the VS 2003, i see a property printer setting. It says "No printer" on the top and there is option to select printer and paper settings etc.. I want to know how will this affect a report rendered by a crystal viewer. I have a web page with a crystal viewer rendering the report on the page. I build...
3
5229
by: Diggler | last post by:
I was working on a report that is populated with three different tables in a strongly-typed dataset. The tables are populated from custom objects rather than directly from SQL Server. I loop through the objects and add the rows one at a time. I then push the dataset to the Crystal Report. The report worked fine, until this morning. I...
0
1040
by: vingtquatre | last post by:
Ijust upgraded from Crystal Reports 6 to Crystal Report XI. Existing reports (lots of them) were converted apparently OK. (That is, they looked fine when viewed with Crystal's design preview). However, none of the embedded formulas work when the report is printed/viewed using VB6 (I'm NOT using the Crystal designer in VB; instead I'm doing...
3
4298
rizwan6feb
by: rizwan6feb | last post by:
I am developing a database application in Visual Studion 2008 (VB.Net) . I want to create a stock report which receives data from 2 different tables i.e Products and Stock. I have designed the report but it shows a blank report (only headings, but no data) I have used the following code to populate report Dim r As New rptStock ...
0
7467
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7807
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7419
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7756
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.