How to Use Crystal Reports in ASP.NET 3.5
- 1). Open Visual Studio .NET, open your ASP.NET project and right-click the "Solution Explorer." Click "Add" and select "Crystal Report" from the drop-down list to add a new Crystal Report to your website.
- 2). Tick the "As a Blank Report" radio button when the "Crystal Report Gallery" window appears and click "OK." This will open your new report file in the "Crystal Report Designer" window.
- 3). Right-click on "Details Section," select "Database" and click "Add/Remove Database" to add a new database in your Crystal Report.
- 4). Click the small "+" in front of the "OLE DB (ADO)" option to expand it when the "Database Expert" window pops up. A "OLE DB (ADO)" window will appear.
- 5). Click "Microsoft OLE DB Provider for SQL Server" and click "Next." Enter your connection information and click "Next." Click "Finish" and you will see the "Database Expert." Your database tables will also be visible.
- 6). Click the small "+" you see in front of the "Pubs" database, expand the "Tables" category and select the "Stores" table. Click the small ">" to include this table in your "Selected Tables" section. Note that you can add more than one table. You will see the table and its fields in the "Database Fields" section.
- 7). Locate the fields you need in your report and drag them to the "Details" section of the report. The "Page Header" section will show the field names. Save the Crystal Report and select a location on your hard disk drive. The report file will be created at that location.
- 1). Go to Visual Studio .NET toolbox and locate the "Crystal Report Viewer." Drag it onto your ASP.NET webpage. Right-click on it and select "Properties" to open the "Properties" window for your control.
- 2). Click the small "[...]" you see after the "Data Binding" property. This will open the "Data Binding" window. Click on "Report Source."
- 3). Tick the "Custom Binding Expression" radio button you see in the resulting window. Navigate to where you saved the report file and select it. The "Crystal Report Viewer" will display a preview of the report file. Click "OK" to insert the Crystal Report Viewer controls and set its properties. Note that the data in the preview is not your real data. Real data will be fetched only when the report is run.
- 4). Open the "Code Behind" file (.aspx.vb) and call the "Databind" method on "Page Load Event." Compile and run your ASP.NET 3.5 Web page and it will display the Crystal Report using real data, fetched from your database.
Creating the Report File
Creating a Crystal Report Viewer Control
Source...