Skip to main content

Posts

Showing posts with the label Crystal Report

Crystal Report with ASP.net

There are many approaches you can take to link crystal report with asp.net . In this article I’m going to discuss some methods. Direct Method – In here we are creating the report using crystal report and link it with the aspx.  There are two ways of doing this. Integrated Security (go to article) Using credentials (in here we want to provide server user name and password) (go to article)     Data Set Method - In here we are creating the datasets and using data sets we are creating reports. Data set with same project (go to article ) Data set with Different project (go to article ) Object Method – In this method we are binding a object collection to the report. Object with Crystal Report  

Crystal Report with Asp.NET – Using Data Objects

First of all you want to  create a database connection to your SQL Server . (Optional – you can find many other ways if you are already known.)  Then crate you Business Class which marches to the data base table. for a example Customer.cs file public class Customer { public int Year { get ; set ; } public String Name { get ; set ; } } Then go to query editor and run this SQL, It is better you have some records inserted in the table. SELECT TOP (1) Name, Year FROM Table1 FOR XML AUTO, Elements It will return following kind of a XML. thus copy it and save it as Table1.xml (for that add a new XML file to the project and paste the content and save it.) <? xml version ="1.0" encoding ="utf-8" ? > < Table1 > < Name > Amal </ Name > < Year > 12 </ Year > </ Table1 > Then add a new crystal report by selecting a black report option.   Now go to the database Expert and select .Net Object from the Tree men...

Crystal Report With Asp.NET – Data Set in Different Project

When architecting the system some types you might layering the application to Data Layer and Presentation Layer. Therefore you normally put the Dataset to the data layer, But your report in the presentation layer. Thus When you are creating the crystal report in Presentation Layer it is not showing the Data Set which is in the Data Layer.   There fore when you are creating the report using data set, it is shown as empty.   Thus you want to copy the dataset to the project. For that copy and paste the data set to the project. Now you can design your report by adding the dataset as previous article . After design the report you can delete the dataset i the project (WebApplication) Now we want to call the report when the page is loading. Report.aspx.cs protected void Page_Load( object sender, EventArgs e) { ReportDocument CollReport = new ReportDocument (); string reportPath = Server.MapPath( "CrystalReport.rpt" ); CollReport.Load(reportPath); D...

Crystal Report with Asp.NET – Direct method using server credentials

In this we are going to create a database connection using server user name and password. For this do the all the steps as previous post until Make New Connection to Create a New DB connection, in there give server name, username and password. If everything is correct you can select the server database in your list.   Then click next and finished the wizard. So you can view your tables in the Field explorer as previous post . Now you can design your report by drag and dropping fields. Finally save you report as report1.rpt.    Now not like the previous, we want to give server credentials when we Load the report. Thus following codes you can use to  give credentials in report.aspx protected void Page_Load( object sender, EventArgs e) { ReportDocument CollReport = new ReportDocument (); string reportPath = Server.MapPath( "Report1.rpt" ); CollReport.Load(reportPath); CollReport.SetDatabaseLogon( "username" , "password" , "...

Crystal Report in ASP.NET – Direct Method Using Integrated Security

Create new Asp.Net Web Application or a Web Site Add new crystal report to the application.               Then select the Black Report. (You can also select the other options (Ex:-Wizard,) ) when you are familiar.   Next we want to add the data base connection to create the report. In Here I’m going to use Integrated security .  Thus in the Field Explorer..            Then click Make New Connection to Create a New DB connection       As above you want to give the server name and check the Integrated Security . If every this is correct now you can select your database from the database list.  Then click finish to Finished the wizard. Then under connection your database will be shown. Then select the tables you want to add the report and add them.    Then Click ok to continue. Now y...

Multiple Columns in Crystal Report

Some times you might want to print the report Column wise so this is simple. what you have to do is go to Section Expert and –> Details and check the Format with Multiple Columns. then Layout tab will appear . then  configure the relevant values. after pressing ok , you can see your detail section is resized. Now you are done.

Hide and Show Crystal Report’s Sub Report when we need

Refer to my previous post assume you want to display the sub report only data is available. therefore you can check the data for row availability and if rows are exists you can  display the report. In my example we are placed our sub report in section 4 in main report. thus we can use following code to display the sub report only data is available. if (dts.Rows.Count > 0) { Ci.Subreports[ "SubBalance" ].SetDataSource(( DataTable )dts); } else { Ci.ReportDefinition.Sections[3].SectionFormat.EnableSuppress = true ; }

How to Create a Crystal Report Sub Report in C#.NET

First you need to create the main report.  (Read .. How to Create a Crystal Report using Data sets in C#.NET) Then right click the area which you want to insert a sub report. In my example I’m going to create a sub report for displaying InvoiceNumber , Balance (refer to my previous post) . Then place the report and design the sub report as we did in the main report. Finally right click the sub report and go to Format Object and Give the Object name as SubBalance .  also give the report name as SubBalance when the time of creating the report. Now your main report looks like .. Now you need to load data to the sub report as well as main report when we press the select button using data adapters. (refer Previous post ) private void btnView_Click( object sender, EventArgs e) { SqlConnectionStringBuilder cb = new SqlConnectionStringBuilder (); cb.UserID = "sa" ; cb.Password = "sa123" ; cb.InitialCatalog = "CustomerInfo" ; // Create S...

How to Create a Crystal Report using Data sets in C#.NET

Assume that you already SQL server database created and table also. Following illustrate our table structure and data. CustomerName InvoiceNum TotalAmount Paid Balance Amal 10001S 1000.00 900.00 100.00 Amal 10002S 2500.00 2000.00 500.00 Amal 10003S 1800.00 1500.00 300.00 Amal 10004S 2500.00 2000.00 500.00 Nimal 10005S 3000.00 3000.00 0.00 Nimal 10006S 1000.00 1000.00 0.00 Nimal 10007S 1500.00 1500.00 0.00 First you need to have a data connection created. (Read ..How to create a Data Connection to SQL Server using C#.net Wizard)   Then you need to have a Data set created. (Read .. How to Create a DataSet, DataTables, Table Adapter Using C#.NET Wizard)   In here I’m going to create a report with main data by customer name (CustomerName, InvoiceNum , TotalAmount) therefore i need a data table with relevant fields. To add a Crystal Report go to Project –> Add new items –> Reporting –> CrystalReport .   Than give a...

Logon failed. Details: crdb_adoplus : Object reference not set to an instance of an object

Logon failed. Details: crdb_adoplus : Object reference not set to an instance of an object. Error in File C:\DOCUME~1\JASONML\ASPNET\LOCALS~1\Temp\ReleasedDrawings {AA4B9DD0-25C5-40B9-9847-74F743ADEAED}.rpt: Unable to connect: incorrect log on parameters. This error occurs because of error error in used dataset. Recreate the dataset will solve the problem.

System.Runtime.InteropServices.COMException: The system cannot find the file specified

[COMException (0x80004005): The system cannot find the file specified.] This Error occurs when using crystal reports as web reporting. There are several reasons for this. Required DLL are missing in web setup Required Reports files are missing in web setup Access Permisions Required DLL and Reports are missing in web setup To over come this you can create web setup as below (VS2008) Go to Other Projects , Add Web Set up Project. Then Right Click the Project and goto Properties and then Prerequisites and select crystal Reports Basic for Visual Studio.. And add other files (sometimes reports files are not including please be careful) Note :- If your error is still occur use filemon (google it and get the first link) and monitor your files when browsing. it will give what is the actual cause of the error. Access Permission Give full permission to asp.net (give permissions in IIS , Windows/Temp, wwwroot )