ADO.NET Reports in Web Forms Viewer:
A web form has been created using the web form viewer to carry reports named CrystalReport1.rpt. The CrystalReport1.rpt is connected to the sample database Xtreme.mdb using the ADO.NET and MS OLEDB Jet Provider. To add all the fields in the Xtreme.mdb Customer table to the report. Specify the data and bind the report to the web form viewer
In the Solution Explorer, click WebForm1.aspx. Click View Code in the Solution Explorer. Type: use system.data.oledb in the source file of the web; type: public crystalReport1 ORPT = New CrystalReport1 (); InitializationComponent () call in pageinit () Type: / / Set the connection information oledbconnection oleconn = new oledbconnection ("provider = microsoft.jet.Oledb.4.0;" "data source = c: // program files //" "Microsoft Visual Studio .NET 2003 // Crystal Reports" "//Sample.mdb" );oledbdataadapter dataAdapter = new oledbdataadapter (" Select * from customer ", oleconn; dataset1 dataset = new dataset1 ();
/ / Connect to the database, get the data from the database and disconnect the database to DataAdapter.Fill (Dataset, "Customer");
// Use the Report Engine Object Model to pass the // padded data set to the report ORPT.SetDataSource (DataSet);
// Bind the report object with the data to the web form ViewerCrystalReportViewer1.Reportsource = ORPT;
The ADO.NET report in Windows Form Viewer is similar to the above.