RE: Sub Report can’t resolve relitave path

      I’ve been having an issue where a sub report has a TTX file as a database with a relative path (“.\\Cert_WorksetSpecialText.ttx””). Unfortunately when I open it in the Viewer I receive the Database connection Dialog for that file. If I use hard coded paths for the file it works fine. Also the Main reports TTX has a relative path, and it does not cause any issues.

      simplified code is as follows:

           ReportDocument MainReport = new ReportDocument();

           MainReport .Load(ReportFile);

           MainReport.SetDataSource(DataTable);

           MainReport.VerifyDatabase();

           […]

           ReportDocument SubReportDocument= MainReport.OpenSubreport(SubReportName);

           SubReportDocument.SetDataSource(SubDataTable);

           SubReportDocument.VerifyDatabase();

      When displaying in the viewer I receive:

      as a work around I trued changing the Database.ConnectionInfo to a static Path by doing the following prior to setting the DataSource:

      TableLogOnInfo T = SubReportDocument.Database.Tables[0].LogOnInfo;

      T.ConnectionInfo.LogonProperties[0] = new NameValuePair2(“Field Definition File”, x);

      T.ConnectionInfo.ServerName = x;

      T.ConnectionInfo.IntegratedSecurity = true;

      SubReportDocument.Database.Tables[0].LogOnInfo.ConnectionInfo.Attributes.Collection[4] = new NameValuePair2(“QE_ServerDescription”, x);

              SubReportDocument.Database.Tables[0].ApplyLogOnInfo(T);

      Though on ApplyLogOnInfo it reset the path back to “.\\Cert_WorksetSpecialText.ttx”. Not using the ApplyLogOnInfo did not have any noticeable effect either. I had read somewhere that setting the location after ApplyLogOnInfo would do the trick, so I tried:


           SubReportDocument.Database.Tables[0].Location = T.TableName;


      This only created an “Connection not possible” error in VS.


      I cannot change the RPT files, since our current system required the dynamic pathing in the existing files, and I am only replacing one part of the system which was based on VB 6.0 and a much older version of CR (which stopped working after a server update).


      I am currently using the latest update (13.0.16.1954) and tried an earlier v13 as well.


      And suggestions or help would be much appreciated.


      Thanks in advance.




      Hi Marcus,   I've ask DEV if we can alter/add a new open method to use the Original Location.     By default CR opens a the report and makes a copy of it in the Users \temp folder:   C:\Users\%USER%\AppData\Local\Temp   Using the feature "Same As report" removes the fully qualified path to the data file:     But since CR now uses the Users \temp folder as the Report location it expects the data files to be in the same place, the users \temp folder.   Work around for now is to copy the data files to that…

      User Rating: Be the first one !
      Add Comment
      1 Answers

        Hi Marcus,

         

        I’ve ask DEV if we can alter/add a new open method to use the Original Location.

         

         

        By default CR opens a the report and makes a copy of it in the Users \temp folder:

         

        C:\Users\%USER%\AppData\Local\Temp

         

        Using the feature “Same As report” removes the fully qualified path to the data file:

         

         

        But since CR now uses the Users \temp folder as the Report location it expects the data files to be in the same place, the users \temp folder.

         

        Work around for now is to copy the data files to that location.

         

        I tested and it works for both main and subreports.

         

        I’ll create a case and add this Enhancement request for SP 17, not sure if they can do it that quick but we’ll see.

         

        Same as this case also – Re: Is the ‘Same as Report’ option still available in the ‘Set Datasource location’ option?

         

        Incident 238245 / 2016 / ER – OpenReportByDefault -same as Report

        KBA – 2298839

         

        Thanks again

        Don

        Add Comment

        Your Answer

        By posting your answer, you agree to the privacy policy and terms of service.