日期:2014-05-20  浏览次数:20816 次

水晶报表数据重复
CrystalReportSource1.ReportDocument.SetDatabaseLogon("sa", "sa", @".\zhao", "ZsOA_SQL");
   
string sql = "SELECT dbo.tUsers.UserName, dbo.tUsers.UserPassword,dbo.tUsers.RealName, dbo.tSysLogs.UserName AS Expr1, dbo.tSysLogs.EventContent,dbo.tSysLogs.UpdateTime,dbo.tUsers.UserID FROM dbo.tUsers LEFT JOIN dbo.tSysLogs ON dbo.tUsers.UserID =dbo.tSysLogs.UserID WHERE (dbo.tUsers.UserID =12) AND (dbo.tSysLogs.UserName = 'Cr')";

  string DBConfig_sql = @"Data Source=.\zhao;Initial Catalog=ZsOA_SQL;User ID=sa;Password=sa";
  DataSet ds = new DataSet();
  SqlConnection sqlCon = new SqlConnection(DBConfig_sql);
  SqlCommand sqlCmd = new SqlCommand(sql, sqlCon);
  SqlDataAdapter sqlAd = new SqlDataAdapter();
  sqlAd.SelectCommand = sqlCmd;
  sqlAd.Fill(ds, "sql");
  CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport3.rpt"));
  CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["sql"]);
  CrystalReportSource1.DataBind();
  CrystalReportViewer1.ReportSource = CrystalReportSource1;
  CrystalReportViewer1.DataBind();




头疼一天了!~


------解决方案--------------------
你的SQL语句在数据库中执行时有没有重复呢?
表之间有没有设置关系?