<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Subreport get and set an SQL query in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631818#M4738352</link>
    <description>&lt;P&gt;I can get the SQL statement of my main report so I think it is based on a Command.&lt;/P&gt;&lt;P&gt;For my subreports I don't know but I can't get the SQL statement like with the main report. I don't know how it work.&lt;/P&gt;&lt;P&gt;And yes, in the code I gave myReport should be mySubreport.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jun 2022 07:15:52 GMT</pubDate>
    <dc:creator>pierrestage</dc:creator>
    <dc:date>2022-06-10T07:15:52Z</dc:date>
    <item>
      <title>Subreport get and set an SQL query</title>
      <link>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaq-p/12631814</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;For my project, I need to change the name of the tables of my project's data&lt;/P&gt;
  &lt;P&gt;I'm using the lastest version of CR for Visual Studio in C#&lt;/P&gt;
  &lt;P&gt;To do it, I get the SQL query of the report, I change the names I want in the string and I set the new SQL query. It work perfectly&lt;/P&gt;
  &lt;P&gt;But now, I need to do the same thing with subreports and I can't do the same simple technique.&lt;/P&gt;
  &lt;P&gt;When I get the SQL statement with "myReport.ReportClientDocument.SubreportController.GetSubreport("name").RowsetController.GetSQLStatement(groupPath, out temp)" I have an error "Missing parameter values.".&lt;/P&gt;
  &lt;P&gt;And even when I bypass this problem,&lt;BR /&gt;I tried to redo links by changing the name of the tables&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;SubreportLinks subreportLinks = new SubreportLinks();
                        SubreportLink subreportLink = new SubreportLink();
                        subreportLinks.Add(subreportLink);
                        subreportLink.LinkedParameterName = "{?Pm-DOSSIER_HISTO.DOSS_ID_DOSSIER}";
                        subreportLink.MainReportFieldName = "{DOSSIER_HISTO.DOSS_ID_DOSSIER}";
                        subreportLink.SubreportFieldName = "{JOURNAL_VIEW.JOUR_ID_DOSSIER}";
                        myReport.ReportClientDocument.SubreportController.SetSubreportLinks("name", subreportLinks);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I also tried to redo RecordSelectionFormula by changing the name of the tables and despite all this I have a mistake "Invalid field name".&lt;/P&gt;
  &lt;P&gt;I can't find the solution and I need to finish this project as soon as possible. I would be very grateful if someone could help me&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 09:10:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaq-p/12631814</guid>
      <dc:creator>pierrestage</dc:creator>
      <dc:date>2022-06-08T09:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Subreport get and set an SQL query</title>
      <link>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631815#M4738349</link>
      <description>&lt;P&gt;You can't edit the SQL, only way to change it is to base the reports on Commands. ( Actuall ynot completely true since you can change a data source from a Table to a command but for only one table)&lt;/P&gt;&lt;P&gt;You are should never change the Table or structure of the reports data source in code.&lt;/P&gt;&lt;P&gt;That info is saved in the RPT file SDK Auto-Maps the fields, if they can't be found the engine simply deletes the fields and likely breaking the report.&lt;/P&gt;&lt;P&gt;You do need to be logged onto the Datasource the subreport needs also, due to the SQL is dynamically generated based on the DB Server type..&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 19:52:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631815#M4738349</guid>
      <dc:creator>former_member11696</dc:creator>
      <dc:date>2022-06-08T19:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Subreport get and set an SQL query</title>
      <link>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631816#M4738350</link>
      <description>&lt;P&gt;In my project there are several different tables containing the same data with the same column names but containing older data. That's why I want to change the tables dynamically. It works very well for the main report.&lt;/P&gt;&lt;P&gt;here is my code for the report&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;// Get SQL request
               string request;
               var groupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
               string temp = String.Empty;
               myReport.SetDatabaseLogon(/*"UserId"*/, /*"Password"*/);
               request = myReport.ReportClientDocument.RowsetController.GetSQLStatement(groupPath, out temp);

// Connection to data base
                ConnectionInfo connectionInfo = new ConnectionInfo(myReport.Database.Tables[0].LogOnInfo.ConnectionInfo);
                connectionInfo.Password = /*"PassWord"*/;
                connectionInfo.ServerName = /*"ServerName"*/;

////////////////
// I add a WHERE or I change table names in the request
////////////////

// Set the new SQL request 
               myReport.SetSQLCommandTable(connectionInfo, "newTableName", request);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why wouldn't it work with the subreports ? &lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 07:26:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631816#M4738350</guid>
      <dc:creator>pierrestage</dc:creator>
      <dc:date>2022-06-09T07:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Subreport get and set an SQL query</title>
      <link>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631817#M4738351</link>
      <description>&lt;P&gt;Yes you must log onto the Server before changes can be made.&lt;/P&gt;&lt;P&gt;So is the Main report based on a Command?&lt;/P&gt;&lt;P&gt;As noted, you can't change the SQL directly if the report is not based on a Command originally.&lt;/P&gt;&lt;P&gt;Are the subreports based on a Command?&lt;/P&gt;&lt;P&gt;And should myReport be mySubreport?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 20:15:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631817#M4738351</guid>
      <dc:creator>former_member11696</dc:creator>
      <dc:date>2022-06-09T20:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Subreport get and set an SQL query</title>
      <link>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631818#M4738352</link>
      <description>&lt;P&gt;I can get the SQL statement of my main report so I think it is based on a Command.&lt;/P&gt;&lt;P&gt;For my subreports I don't know but I can't get the SQL statement like with the main report. I don't know how it work.&lt;/P&gt;&lt;P&gt;And yes, in the code I gave myReport should be mySubreport.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 07:15:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631818#M4738352</guid>
      <dc:creator>pierrestage</dc:creator>
      <dc:date>2022-06-10T07:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Subreport get and set an SQL query</title>
      <link>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631819#M4738353</link>
      <description>&lt;P&gt;See my sample app that can get/set the log on info:&lt;/P&gt;&lt;H4&gt;&lt;A rel="nofollow" href="https://blogs.sap.com/2016/02/17/how-to-parameters-in-crystal-reports-for-visual-studio-net/"&gt;how-to-parameters-in-crystal-reports-for-visual-studio-net&lt;/A&gt;&lt;/H4&gt;&lt;P&gt;See if it gets the the SQL from the subreports, you may need to modify the sample.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 16:37:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/subreport-get-and-set-an-sql-query/qaa-p/12631819#M4738353</guid>
      <dc:creator>former_member11696</dc:creator>
      <dc:date>2022-06-14T16:37:18Z</dc:date>
    </item>
  </channel>
</rss>

