2
CrystalReportAct crt = new CrystalReportAct();
sqlcon.Open();

sql = "SELECT EmpLog.Date, JobCategory.JobDesc, 
        Client.CompDesc, Product.ProdName, EmpLog.Actions, EmpLog.Remarks 
        FROM Client 
        INNER JOIN EmpLog ON Client.CompCode = EmpLog.CompCode 
        INNER JOIN JobCategory ON EmpLog.JobCode = JobCategory.JobCode 
        INNER JOIN Product ON EmpLog.ProdCode = Product.ProdCode 
        WHERE (EmpLog.EmpID = '"+empID+"')";

SqlDataAdapter adp = new SqlDataAdapter(sql, sqlcon);
DataSet ds = new DataSet();
adp.Fill(ds, "Client");
adp.Fill(ds, "Emplog");
adp.Fill(ds, "JobCategory");
adp.Fill(ds, "Product");

crt.SetDataSource(ds);
crystalReportViewer1.ReportSource = crt;

这运行但输出错误。输出几乎是 80 行,而不仅仅是 3 行。

4

1 回答 1

0

在 crt.SetDataSource(ds) 语句中还要指定表名,否则它会占用总行数。

于 2013-02-06T09:20:25.977 回答