Process of Creating Crystal Reports using Aspnet and C#: Step 1:Right click the solution Explorer and
click on add new item Step 2:Add a Crystal Report from the Dialogue box. Step 3:Select the Radio Button(using the Report Wizard) from the Crystal Reports Gallery and choose a Standard Expert and click OK button. Step 4:Here we have to add Database..Select the Create New connection from the available Datasources window and click OLEDB(ADO) Step 5:select A new connection and then select a provider from the list (Microsoft OLEDB Provider for SQL Server) Step 6:Enter the server name and select the Database and click the Integrated Security and press next and click finish button. Step 7:Now,come back to Standard Report Creation Wizard and select the Table from the Database. Step 8:Select the required fields to display in the Crystal Report from the table Step 9:Select the style from the availble styles window (Ex:Standard) and Click Finish Step 10:Now we have to add one WebForm from Add New Item and press Add. Step 11:Here,we have to import two references that is CrystalDecisions.CrystalReports.Engine CrystalDecisions.Shared Step12:Now,add one Crystal Report Viewer from the Toolbox Step13:Now we have to import the following namespaces in the defalut.aspx.cs using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.Data.SqlClient; Step14:Declare the variable ReportDocument report = new ReportDocument(); Step15:Next,write the following code in the page Load Event pt.Load(@"E:\practices\update\emp_details\crystalreports\CrystalReport.rpt" ); crystalReportViewer1.ReportSource = report; crystalReportViewer1.RefreshReport();
Second Way:
Step-1 Create a new website using Visual Studio. Step-2 Right click your website name in solution explorer. click Add New Item. The Add New Item dialog Box appears, Click on CrystalReport and then Add. Step-3 Crystal Report Gallery appears. Choose As a Blank Report Click Ok Step-4 Database Expert Dialog Box Appears Expand Create New Connection Expand on OLE DB(ADO) Choose your Data Provider..(Here, Microsoft OLE DB Provider for SQL Server) Click NEXT Write your Server name. Your UserId and Password Choose your Database Click Finish Step-5 Under OLE DB(ADO) you will see that the database that you choose earlier is nw visible. Expand it. Choose your table and click on > button. Click on OK. Step-6 Under Field Explorer tab, you can see the name of your selected table. Drag the columns to the specified columns in the Report. Step-7 Click on the Main Report Preview to see the preview of the report. Step-8 Go to your Default.aspx, Drag CrystalReportViewer Control from Crystals Report Category Press F4 to Open the Properties Window, Specify its ReportSourceID Property to the Report You have created earlier. Step-9 Press F5 to debug your Application.