我用水晶报表的推模式制作报表,一切都已经 好了,打包的时候我把一些模块都加上了,本机上没有任何问题,可是当我要装到一个没有装水晶报表的机器上时,用到水晶报表就会弹出登录的对话框。我是用sql语句从数据库中提取数据,然后给dataset,就是推模式,推模式也要设置登陆信息吗?资料说好像不需要啊!各位请帮忙,多谢了。

解决方案 »

  1.   

    Push模式应该是不用的,可能你的代码写得有问题,它自己初始化的时候去“Pull”了
      

  2.   

    如果你用的是水晶报表的推模式,一般不用设置登陆信息,但是要这样写:obj.SetDataSource(this.ds.Tables["tablename"]);如果你写成了obj.SetDataSource(this.ds)就会有登陆框的。还有一点要注意:
    如果你用到了子报表,一定要处理://Go through each sections in the main report and identify the subreport by name
       crSections = crReportDocument.ReportDefinition.Sections;   foreach(Section crSection in crSections)
       {
        crReportObjects = crSection.ReportObjects;
        //loop through all the report objects to find all the subreports
        foreach(ReportObject crReportObject in crReportObjects)
        {
         if (crReportObject.Kind == ReportObjectKind.SubreportObject)
         {
          //you will need to typecast the reportobject to a subreport 
          //object once you find it
          crSubreportObject = (SubreportObject)crReportObject;      //open the subreport object
          crSubReportDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
          //Once the correct subreport has been located pass it the 
          //appropriate dataset
          if(crSubReportDoc.Name == "FirstSub") 
          {
           //crSubReportDoc.Database.Tables[0].SetDataSource(ds);
           crSubReportDoc.SetDataSource(ds);
          }
         }
        }
       }
       crystalReportViewer1.ReportSource = crReportDocument;同样crSubReportDoc.SetDataSource(ds);改为:crSubReportDoc.SetDataSource(ds.Tables["tablename"]);