Click here to Skip to main content
15,891,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
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.
C#
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;
           //}

       }
Posted
Updated 19-Sep-13 10:09am
v2
Comments
joshrduncan2012 19-Sep-13 13:29pm    
Please format your code properly using the pre tags.
Kschuler 19-Sep-13 16:07pm    
Saying "Code not working" is not going to get you any answers. We don't know HOW it is supposed to work and we don't know why it isn't working right now. Please tell us what you mean by not working. Are you getting an error? If so, what is the exact error message and which line of code is blowing up? If you are not getting an error, please tell us what your code is currently doing and then explain what you want it to do.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900