VS 2008的水晶报告和一些报告不起作用,而有些报告在Windows Server 2012中 [英] crystal report for VS 2008 and some reports aren't working while some are in Windows server 2012

查看:52
本文介绍了VS 2008的水晶报告和一些报告不起作用,而有些报告在Windows Server 2012中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为VS 2008使用crystal report 10.5,而有些报告在Windows server 2012中没有用。在Windows Server 2003中一切都很好。



代码工作

在页面加载下调用的函数。

  private   void  SetReport()
{
尝试
{

if ((ddlSystemID.Items.Count > 0 )&&(EquipmentID!= String .Empty))
{
ReportDocument reportDocument;

IMS_DashBoardConsolidatedReportBLL objIMS_DashBoardConsolidatedReportBLL = new IMS_DashBoardConsolidatedReportBLL();
// DataTable dtrf = new DataTable();
// dtrf =
string conString = Common .GetConnectionStringsSection()。ConnectionStrings [ connectionStrings]。ConnectionString;
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(conString);
string UserID = builder.UserID;
string 密码= builder.Password;
string DataSource = builder.DataSource;
string InitialCatalog = builder.InitialCatalog;

string reportPath = Server.MapPath( 〜//报告// AlarmNotificationHistoryReport.rpt);


reportDocument = new ReportDocument();

reportDocument.Load(reportPath);
// reportDocument.SetDatabaseLogon(UserID,Password,DataSource,InitialCatalog);

DataSet ds = objIMS_DashBoardConsolidatedReportBLL.FillIMSDashBoardConsolidatedReport(EquipmentID);
ds.Tables [ 0 ]。TableName = AlarmNotificationHistory;
reportDocument.SetDataSource(ds);
CrystalReportViewer1.EnableDatabaseLogonPrompt = false ;

CrystalReportViewer1.ReportSource = reportDocument;
CrystalReportViewer1.DataBind();

// ReportDocument reportDocument;
// string reportPath = Server.MapPath(〜// Reports // CRSensorDataReport.rpt);

// IMS_SensorDataBLL objIMS_SensorDataBLL = new IMS_SensorDataBLL();
/// / DataTable dtrf = new DataTable();
/// / dtrf =

// reportDocument = new ReportDocument();
// reportDocument.Load(reportPath);
// reportDocument.SetDataSource(objIMS_SensorDataBLL.GetIMS_SensorDataReport(iSystemID,iSensorType,iParamName,sFromDate,sToDate));

// CrystalReportViewer1.ReportSource = reportDocument;
// CrystalReportViewer1.DataBind();
}

}
catch (例外ex)
{
Common.showMessage(ex.Message, this );
}
}



代码不工作

在页面加载下调用的函数。

  public   void  ViewReportCR()
{
ReportDocument reportDocument = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();

string conString = Common.GetConnectionStringsSection()。ConnectionStrings [ 的ConnectionStrings]的ConnectionString。
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(conString);



reportDocument.Load(Server.MapPath( 〜 //Reports//CRSensorDataReport.rpt));
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = builder.DataSource;
connectionInfo.DatabaseName = builder.InitialCatalog;
connectionInfo.UserID = builder.UserID;
connectionInfo.Password = builder.Password;
connectionInfo.Type = ConnectionInfoType.SQL;
connectionInfo.IntegratedSecurity = false ;

TableLogOnInfo rptTableLogOnInfo = new TableLogOnInfo();
rptTableLogOnInfo.ConnectionInfo = connectionInfo;
for int i = 0 ; i< reportdocument.database.tables.count; i ++)>
reportDocument.Database.Tables [i] .ApplyLogOnInfo(rptTableLogOnInfo);

if (ddlSystemID.SelectedIndex!= 0
reportDocument .SetParameterValue( @ ip_SystemID,ddlSystemID.SelectedValue);
else
reportDocument.SetParameterValue( @ip_SystemID 0 );
if (ddlSensorType.SelectedIndex!= 0
reportDocument.SetParameterValue(< span class =code-string>
@ ip_SensorType,ddlSensorType.SelectedValue);
else
reportDocument.SetParameterValue( @ip_SensorType, - 1);
if (ddlParamName.SelectedIndex!= 0
reportDocument.SetParameterValue(< span class =code-string> @ ip_ParamName,ddlParamName.SelectedValue);
else
reportDocument.SetParameterValue( @ip_ParamName 0 );
if (txtFromDate.Text!=
reportDocument.SetParameterValue( @ ip_FromDate,txtFromDate.Text );
else
reportDocument.SetParameterValue( @ip_FromDate );
if (txtToDate.Text!=
reportDocument.SetParameterValue( @ ip_ToDate,txtToDate.Text );
else
reportDocument.SetParameterValue( @ip_ToDate );

// if(ddlSystemID.SelectedIndex!= 0&& txtFromDate.Text! =&& txtToDate.Text!=&& reportDocument.Rows.Count!= 0)
// {



CrystalReportViewer1.ToolbarStyle.Width = new 单位( 100%);
CrystalReportViewer1.ReportSource = reportDocument;



CrystalReportViewer1.Visible = true ;
// }

}

解决方案

检查这个



Crystal Reports XI不适用于Windows Server 2008或任何64位环境 [ ^ ]

Crystal Reports服务包和版本 [ ^

I am using crystal report 10.5 for VS 2008 and some reports aren't working while some are in Windows server 2012. In windows server 2003 all are fine.

Code working
Function called under page load.

private void SetReport()
       {
           try
           {

               if ((ddlSystemID.Items.Count > 0) && (EquipmentID != String.Empty))
               {
                   ReportDocument reportDocument;

                   IMS_DashBoardConsolidatedReportBLL objIMS_DashBoardConsolidatedReportBLL = new IMS_DashBoardConsolidatedReportBLL();
                   //DataTable dtrf = new DataTable();
                   //dtrf =
                   string conString = Common.GetConnectionStringsSection().ConnectionStrings["connectionStrings"].ConnectionString;
                   SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(conString);
                   string UserID = builder.UserID;
                   string Password = builder.Password;
                   string DataSource = builder.DataSource;
                   string InitialCatalog = builder.InitialCatalog;

                   string reportPath = Server.MapPath("~//Reports//AlarmNotificationHistoryReport.rpt");


                   reportDocument = new ReportDocument();

                   reportDocument.Load(reportPath);
                   //      reportDocument.SetDatabaseLogon(UserID, Password, DataSource, InitialCatalog);

                   DataSet ds = objIMS_DashBoardConsolidatedReportBLL.FillIMSDashBoardConsolidatedReport(EquipmentID);
                   ds.Tables[0].TableName = "AlarmNotificationHistory";
                   reportDocument.SetDataSource(ds);
                   CrystalReportViewer1.EnableDatabaseLogonPrompt = false;

                   CrystalReportViewer1.ReportSource = reportDocument;
                   CrystalReportViewer1.DataBind();

                   //ReportDocument reportDocument;
                   //string reportPath = Server.MapPath("~//Reports//CRSensorDataReport.rpt");

                   //IMS_SensorDataBLL objIMS_SensorDataBLL = new IMS_SensorDataBLL();
                   ////DataTable dtrf = new DataTable();
                   ////dtrf =

                   //reportDocument = new ReportDocument();
                   //reportDocument.Load(reportPath);
                   //reportDocument.SetDataSource(objIMS_SensorDataBLL.GetIMS_SensorDataReport(iSystemID, iSensorType, iParamName, sFromDate, sToDate));

                   //CrystalReportViewer1.ReportSource = reportDocument;
                   //CrystalReportViewer1.DataBind();
               }

           }
           catch (Exception ex)
           {
               Common.showMessage(ex.Message, this);
           }
       }


Code not working
Function called under page load.

public void ViewReportCR()
       {
           ReportDocument reportDocument = new ReportDocument();
           ParameterField paramField = new ParameterField();
           ParameterFields paramFields = new ParameterFields();
           ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();

           string conString = Common.GetConnectionStringsSection().ConnectionStrings["connectionStrings"].ConnectionString;
           SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(conString);



           reportDocument.Load(Server.MapPath("~//Reports//CRSensorDataReport.rpt"));
           ConnectionInfo connectionInfo = new ConnectionInfo( );
           connectionInfo.ServerName =builder.DataSource;
           connectionInfo.DatabaseName =  builder.InitialCatalog;
           connectionInfo.UserID = builder.UserID;
           connectionInfo.Password =  builder.Password;
           connectionInfo.Type = ConnectionInfoType.SQL;
           connectionInfo.IntegratedSecurity = false;

           TableLogOnInfo rptTableLogOnInfo =new TableLogOnInfo( );
           rptTableLogOnInfo.ConnectionInfo=connectionInfo;
               for(int i=0;i<reportdocument.database.tables.count;i++)>
                       reportDocument.Database.Tables[i].ApplyLogOnInfo( rptTableLogOnInfo );

           if (ddlSystemID.SelectedIndex != 0)
               reportDocument.SetParameterValue("@ip_SystemID", ddlSystemID.SelectedValue);
           else
               reportDocument.SetParameterValue("@ip_SystemID", 0);
           if (ddlSensorType.SelectedIndex != 0)
               reportDocument.SetParameterValue("@ip_SensorType", ddlSensorType.SelectedValue);
           else
               reportDocument.SetParameterValue("@ip_SensorType", -1);
           if (ddlParamName.SelectedIndex != 0)
               reportDocument.SetParameterValue("@ip_ParamName", ddlParamName.SelectedValue);
           else
               reportDocument.SetParameterValue("@ip_ParamName", 0);
           if (txtFromDate.Text != "")
               reportDocument.SetParameterValue("@ip_FromDate", txtFromDate.Text);
           else
               reportDocument.SetParameterValue("@ip_FromDate", "");
           if (txtToDate.Text != "")
               reportDocument.SetParameterValue("@ip_ToDate", txtToDate.Text);
           else
               reportDocument.SetParameterValue("@ip_ToDate", "");

           //if (ddlSystemID.SelectedIndex != 0 && txtFromDate.Text != "" && txtToDate.Text != "" && reportDocument.Rows.Count != 0)
           //{



               CrystalReportViewer1.ToolbarStyle.Width = new Unit("100%");
               CrystalReportViewer1.ReportSource = reportDocument;



               CrystalReportViewer1.Visible = true;
           //}

       }

解决方案

Check this

Crystal Reports XI does not work on Windows server 2008 or any 64-bit environment[^]
Crystal Reports service packs and versions[^]


这篇关于VS 2008的水晶报告和一些报告不起作用,而有些报告在Windows Server 2012中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆