Fields displaying multiple tables in the report

xiaoxiao2021-03-06  50

Crystal Report Use Experience - Show multiple tables in the report (through table association) to give a simple example: Employee Table (employee number? Name of employee name) Department (Department Number)

The request is: SELECT staff table. Name of employees, department table. Department name from the name of the staff WHERE Employee table. Department number = department table. Department number

Procedure (listed several more important places that are more confused at the time) 1. Construction XSD files into employee tables and department tables directly? Don't do any field association 2. Building RPT files Select employee table and department table to establish Link employee department department number -> department number of department name 3. Construction .ASPX file dragged into report control 4. Create a DataSet in .aspx.cs, it is two tables, names, employee table, department The table (and the name of the name dragged into the XSD) SQL statement is: SELECT * FROM employee table Select * from department table

Sample Code try {CrystalReport1 crReportDocument; crReportDocument = new CrystalReport1 (); SqlConnection conn = new SqlConnection ( "server = it003; database = pubs; uid = sa; pwd ="); conn.Open (); DataSet ds = new DataSet ( ); Sqldataadapter ada = new SqldataAdapter ("Select * from authors where au_id like '%" 32 "%'", conn); ada.fill (DS, "authors"); // Fill table name is to DataSet. xsd in the table consistent; SqlDataAdapter ada1 = new SqlDataAdapter ( "select * from titleauthor", conn); ada1.Fill (ds, "titleauthor"); conn.Close (); crReportDocument.SetDataSource (ds); crystalReportViewer1. ReportSource = crReportDocument; TextObject GetTextObject = crReportDocument.ReportDefinition.ReportObjects [ "Text3"] as TextObject; // Style to modify objects GetTextObject.Text = textBox1.Text.Trim (); crystalReportViewer1.RefreshReport (); //GetTextObject.ObjectFormat. EnableSuppress = true; hidden text object} catch (exception ex) {messagebox.show (ex.Message, System Tips ", MessageBoxButtons.ok, MessageBoxicon.Error); }

转载请注明原文地址:https://www.9cbs.com/read-116874.html

New Post(0)