Open rpt file in visual studio




















In order to report from this stored procedure using the arbitrary value of "A" for CustPattern , I modify the form's Load event code, as you can see from the example shown in Figure 7. In this code, I am using none of the objects I created at design time except scnNorthwind.

Most significantly, I am not using an instance of my strongly typed DataSet, dsNorthwind, as the report's data source, but am instead using an untyped ADO. This is extremely important—even though I have designed the report against a strongly typed DataSet, at run time I set its data source to a generic, untyped DataSet object whose structure merely matches that of dsNorthwind.

When I call the Fill method of the DataAdapter object, I do so using the overloaded version that accepts a table name, and I supply Customers as that table name to ensure that dsReport matches dsNorthwind structurally. If I didn't, the report would have come up without any data. It is also possible to design a report directly against a stored procedure much as my first example was designed directly against a table. Setting the parameter's value in code requires some command of the objects, properties, and methods in the various Crystal Reports for Visual Studio.

NET namespaces. Let's take a look. First, you need to configure Crystal Reports for Visual Studio. NET to make stored procedures selectable as data sources for reports. To do this, right-click on a blank area of the report's designer surface and choose Designer Default Settings from the context menus. Next, right-click again on the designer surface and choose Database Set Location from the context menus.

Next, back in the Set Location dialog, you should drill down on the Northwind node, then the Stored Procedures node, and select the spCustomers;1 node. From the Current Data Source combobox, select Customers and then click the Replace button, and, finally, the Close button.

You have now retrofitted this report—originally designed against the Customers table in the Northwind Database, then converted to use a strongly typed dataset as its data source—to use the spCustomers stored procedure to get its data. Because this is a parameterized stored procedure, Crystal Reports for Visual Studio. NET automatically adds a Crystal parameter field with the same name as the stored procedure parameter to your report.

To see this, look in the Field Explorer window, and drill down through the Parameter Fields node to reveal the CustPattern parameter field right below it Figure 8 shows its location. Figure 8 Parameters Now you can once again set cvwMain.

ReportSource, either at design time or in code, to point to the rpt file, or to cbsMain, the ReportDocument component designer instance. If you run the application, you will see that Crystal Reports for Visual Studio. NET automatically invokes a dialog box that requests a value for the CustPattern parameter. Enter any string pattern you'd like, and and it will return only the customers whose CompanyName field value starts with that string.

While it's nice that Crystal Reports for Visual Studio. NET can solicit parameter values and run the report without writing code, in most cases, it's better for applications to solicit those values and pass them to the report programmatically. Figure 9 shows the code necessary for programmatic assignment of parameter values through the Crystal Reports object model, in this case once again assigning the arbitrary value of "A" as the parameter of pdvCustPattern.

Some explanation of this code is necessary. NET parameter fields can be assigned a collection of values. So I have to go along with this and construct a collection that has only one member, assigning "A" as its value. Accordingly, the code creates pvCustPattern, an instance of the CrystalDecisions.

ParameterValues object that accommodates multiple values, and pdvCustPattern, an instance of the CrystalDecisions. ParameterDiscreteValue class that accommodates a single value. Finally, pvCustPattern is assigned to the parameter field via its ApplyCurrentValues method, and the instance of CustomersBasic is assigned to the report viewer's ReportSource property.

While the code may seem a little convoluted, the functionality it delivers makes it worthwhile. The great news here is that although the features are sophisticated, taking advantage of them is easy; reports can be published as Web Services and then used as the ReportSource for a CrystalReportViewer control.

Delete the Service1. Next, right-click CustomersBasic. Now build the project. Then, back in the Windows Forms application, set cvwMain. Alternately, you can add a Web reference for this asmx file to the project and then point cvwMain. ReportSource to an instance of the Web Service class.

Look closely at the code in the class file indented underneath the CustomersBasic. CustomersBasic is the primary class needed to implement the strongly typed report; if you look at its property procedures, you will see that it primarily exposes the report and its various sections, by inheriting from ReportClass and wrapping various members of the ReportDefinition.

Sections collection. CachedCustomersBasic, in turn, implements the ICachedReports interface to create a cached report, and in its CreateReport method, it creates an instance of CustomersBasic the first class. Now look at the code in the class file underneath CustomersBasicService. This one also contains two classes, though this time one is nested within the other.

One difference can be found in its constructor:. The constructor is called from CustomersBasicService's own constructor to point the cached report's webService property to it:.

To sum up: Crystal Report's ReportClass makes strongly typed reports possible; the ICachedReports interface makes it possible to create cached instances of ReportClass; and ReportServiceBase effectively creates a Web Services interface for strongly typed reports, which is compatible with the ICachedReports interface through the latter's webService property.

One more thing. It uses Web Services technology as well. NET reports that exist on that remote machine. This makes it very easy to deploy reports throughout the enterprise: simply install Visual Studio. NET on a server, copy rpt files to the appropriate folder, and they become immediately available throughout the organization via SOAP without requiring any special coding.

Even the relatively simple process of right-clicking a report in an ASP. NET project and selecting "Publish as Web Service" is not necessary; all you have to do is copy the file to the correct folder. But there's a workaround: as long as the URL and ReportPath of a given report are known, and the server firewalled or not is connected to the Internet, you can create a new instance of CrystalDecisions.

ServerFileReport and set these properties on it in code. NET uses it as a wrapper of sorts for its earlier Crystal Enterprise product.

So far, everything I have done on the client has been in a Windows Forms application, but you may want to present reports in ASP. NET Web applications. Fortunately, Crystal Reports for Visual Studio. I'll now show you how to present reports using the ASP.

SAP crystal reports provides two installations. The first is SAP Crystal Reports version for visual studio that is installed for working with crystal reports in visual studio. NET Framework that is installed when the application is deployed on server machine. Upgrading an exist VS app will simply work.

So in the meantime to edit rpt files you'll need the stand-alone Crystal Reports Designer until Support Pack 21 comes along.

Installer warned me that it detected an older version and that it will overwrite it. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Cannot open. Asked 9 years, 8 months ago. Active 5 years, 3 months ago. Viewed 79k times. Community Bot 1 1 1 silver badge. Stanley Stanley 4, 8 8 gold badges 32 32 silver badges 51 51 bronze badges.

Add a comment. Active Oldest Votes. Best of luck with it. I doubt if it's a file association problem as I get the problem even when I directly open the file from Visual Studio. I have followed your test by adding new Crystal Reporting item to the project. That just created a CrystalReport1. It links back here: businessobjects. Ah-hah, that's the problem.

It was available with a 10 day free trial, and I only needed about 10 minutes to make my changes. That said, I would have happily paid whatever they asked for it. If this is something you are only going to need to do once, have you considered downloading a demo version of Crystal?

Of course, if you need to edit these files after the 30 day period is over, you would be better off buying Crystal. Alternatively, if all you need to do is replace a few static literal words, have you tried doing a search and replace in a text editor?

Don't forget to save the original files somewhere safe first! If you have Visual Studio you could edit them through that. Some versions of Visual Studio has Crystal Reports shipped with them.

If not, you will have to find someone who has Crystal Reports and ask then nicely to amend them for you. Or buy Crystal Reports!



0コメント

  • 1000 / 1000