Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9071

Re: Still getting "The report filename was empty" error

$
0
0

In the previous thread I attempted to provide some sample code I used for my test. Here's the meat of it, which gets called during the Page_Load event:

 

        private void ConfigureCrystalWithDbOverride(string ReportFile)

        {

            ConnectionInfo crConn = CreateConnectionInfo();

            ReportDocument rptDoc = new ReportDocument();

            rptDoc.Load(Server.MapPath(ReportFile));

            Tables crTables = rptDoc.Database.Tables;

 

 

 

            foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in crTables)

            {

                tbl.LogOnInfo.ConnectionInfo = crConn;

                tbl.ApplyLogOnInfo(tbl.LogOnInfo);

            }

 

 

 

            // If the selected report has parameters, clear them out first to ensure the viewer prompts each

            // time for user input.

            if (this.crviewer1.ParameterFieldInfo.Count > 0)

                this.crviewer1.ParameterFieldInfo.Clear();

 

 

 

            // Get database logon info from web.config

            Session["DynamicReport"] = rptDoc;   // Save to Session object which will be needed during subsequent postbacks

 

            DisplayReportInViewer(rptDoc);

        }

 

 

 

        private ConnectionInfo CreateConnectionInfo()

        {

            ConnectionInfo crInfo = new ConnectionInfo();

            string conn = ConfigurationManager.ConnectionStrings["MAS_ConnectionString"].ConnectionString;

            SqlConnection sqlConn = new SqlConnection(conn);

            crInfo.ServerName = sqlConn.DataSource;

            crInfo.DatabaseName = sqlConn.Database;

            crInfo.IntegratedSecurity = true;

            return crInfo;

        }

 

 

 

        private void DisplayReportInViewer(ReportDocument rptDoc)

        {

            this.crviewer1.ReportSource = rptDoc;

            this.crviewer1.RefreshReport();

        }

 

I should probably point out one other change from the original environment. Originally we were connecting with SQL authentication and now we're using integrated security. Not sure whether that's relevant to this particular issue, but wanted to make sure it was known.


Viewing all articles
Browse latest Browse all 9071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>