473,395 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 parameterFieldInfo. Here is
code I have cobbled together so far:
// I open the dialog by clicking a command button
private void button1_Click(object sender, System.EventArgs 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 (openFileDialog1.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.NullReferenceException' occurred in
ReportManager.exe

ReportDocument1.Load(openFileDialog1.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.ParameterFields.Count;i++)

{

listBox1.Items.Add(dataDef1.ParameterFields.Curren t.ToString());

dataDef1.ParameterFields.MoveNext();

}

}

}
Nov 16 '05 #1
2 2037
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_
simplelogonviewer.exe.asp>
<http://support.crystaldecisions.com/...es/csharp_win_
dbengine.exe.asp>
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.FileName);

and it should work.

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

foreach (ParameterFieldDefinition parm in
ReportDocument1.DataDefinition.ParameterFields)
{
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
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...
2
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...
1
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...
0
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...
8
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...
1
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...
3
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...
0
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)....
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.