Telerik Forums
Reporting Forum
1 answer
7 views
I'm generating a lot of reports using the ReportProcessor class and the RenderReport function to get the PDF and save it in a share drive.

private byte[] GetReport(int param)
    {
        var reportProcessor = new ReportProcessor();
        var reportSource = new UriReportSource
        {
            Uri = Path.Combine(_environment.ContentRootPath, "Reports", "Report.trdp"),
        };

        reportSource.Parameters.Add(new Parameter("param", param));

        var result = reportProcessor.RenderReport("PDF", reportSource, new Hashtable());
        return result.DocumentBytes;
    }

This works fine. But if I only run the application and get to generate the reports I get:

"An error has occurred while processing Report 'Report':
Unable to establish a connection to the database. Please verify that your connection string is valid. In case you use a named connection string from the application configuration file, make sure the name
is correct and the connection string settings are present in the configuration file of your application.
------------- InnerException -------------
Format of the initialization string does not conform to specification starting at index 0."

The part that I don't understand is that if I go to the page where I have a HTML5 Report Viewer and generate and view a report from the page the error goes away.

I search a lot about this and tried different things and got nothing.

The problem might be related with the appsettings.

We have different configuration for each env and the appsettings.json is merged with appsettings.ENV.json 

I tried to put the con string in the base appsettings and worked fine.

I need a solution because I still need to have diferent connectionstrings in different enviorments and I can't reliable run the report in the viewer before generate the standalone PDF
Dimitar
Telerik team
 answered on 23 May 2024
1 answer
42 views

Hi,

Maybe you want me refer Assign connection string dynamically using report parameter and bindings - Telerik Reporting .I followed the solution, it didn't work . And then I set the 'ConnectionString' to '@ReportParameters.PFDSConnectionString', it also didn't work, even if I add the '.Value'.Pls refer the error.png

But when I set the connection string to the property 'ConnectionString' , it worked. And I tested the parameter rendering, it's also OK. Pls refer the success.png.

I think the C# code is OK. Because when I use the appsetting.json file to injec the connection string.

Set ConnectionString to 'AcosReportsConnection', It's OK too. Pls refer the appsettings.png.

Because now the connection string come from database depending on different input parameters, I need to set the connection string dynamically.

Now I am very confused.

Do you have any suggestiones? Thanks.

 

0 answers
15 views

I use Telerik Reporting Rest Service from Telerik template. I have created a Postgresql source in Report Disigner but I couldnt to connection in TelerikReportRestService.

 

Im using trial version.

1 answer
33 views

Hi everyone. 

 

We have an extremely frustrating problem we are attempting to solve.

We have a .NET 7 Web Application using a Blazor Server hosting model for reporting. The application is containerized and runs as part of a service via AWS Fargate. We have a series of legacy reports that we have converted to '.trdp' format, several of these reports use a named connection string to interact with RDS (AWS SQL DB).

 

We are using the 'Blazor' reporting solution that is merely a wrapper over the HTML5 reporting. The assembly versions are as follows:

Telerik.Drawing.Skia, 17.2.23.1114 
Telerik.Reporting, 17.2.23.1114 
Telerik.Reporting.OpenXmlRendering, 17.2.23.1114 
Telerik.Reporting.Services.AspNetCore, 17.2.23.1114
Telerik.ReportViewer.Blazor, 17.2.23.1114

As part of our build process - we inject a secrets file into the container definition with the credentials for accessing the db. This is modified during launch to include the correct environment db and db credentials:

if (ConnectionUtility.IsRunningInFargate())
{
    // Create new copy of string in memory so we can modify it
    var connectionString = connectionStrings[Constants.ReportingSqlConnectionKey];
    var databaseUriForEnvironment = ConnectionUtility.GetDatabaseUriForEnvironment();
    var databaseForEnvironment = ConnectionUtility.GetDatabaseForEnvironment();

    // Replace placeholders with values
    var protoConnectionString =
        connectionString!
            .Replace("{0}", databaseUriForEnvironment)
            .Replace("{1}", databaseForEnvironment);

    // Important! - This replaces the 'in-memory' connection string that reports use to interact with the primary db
    connectionStrings[Constants.ReportingSqlConnectionKey] = protoConnectionString.TransformSecret(Constants.SettingClass.ConnectionString);
}


The connection string key isn't important here, but it is used to provide the connection key for each report.; 

The Telerik services are injected:

builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp => new ReportServiceConfiguration
{
    ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
    HostAppId = "X.Reporting",
    Storage = new FileStorage(),
    ExceptionsVerbosity = "detailed",
    ReportSourceResolver =
        new CustomReportSourceResolverWithFallBack(
            new TypeReportSourceResolver()
                .AddFallbackResolver(
                    new UriReportSourceResolver(
                        Path.Combine(
                            GetReportsDir(sp))))),
});

 

The resolver is less important, but for the sake of completion:

using Telerik.Reporting;
using Telerik.Reporting.Services;

namespace X.Reporting.Services
{
    public class CustomReportSourceResolverWithFallBack : IReportSourceResolver
    {
        private readonly IReportSourceResolver? _parentResolver;

        public CustomReportSourceResolverWithFallBack(IReportSourceResolver? parentResolver)
        {
            _parentResolver = parentResolver;
        }

        public ReportSource Resolve(string report, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
        {
            var reportDocument = ResolveCustomReportSource(report, operationOrigin, currentParameterValues);

            if (null == reportDocument && null != _parentResolver)
            {
                reportDocument = _parentResolver.Resolve(report, operationOrigin, currentParameterValues);
            }

            return reportDocument;
        }


        private ReportSource ResolveCustomReportSource(string reportId, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
        {
            var reportBook = new ReportBook();
            var splitString = reportId.Split(',').ToList();

            foreach (var report in splitString)
            {
                var uriReportSource = new UriReportSource
                {
                    Uri = $"Reports/{report}.trdp"
                };

                reportBook.ReportSources.Add(uriReportSource);

                if (operationOrigin == OperationOrigin.ResolveReportParameters)
                {
                    reportBook.ReportSources.Add(GetReportParameters(report, currentParameterValues));
                }
            }

            return new InstanceReportSource { ReportDocument = reportBook };
        }

        private ReportSource GetReportParameters(string reportId, IDictionary<string, object> currentParameterValues)
        {
            UriReportSource report = new UriReportSource();

            foreach (var parameterValue in currentParameterValues)
            {
                if (parameterValue.Value is not null and not (string)"standardReport")
                {
                    var par = new Parameter
                    {
                        Name = parameterValue.Key,
                        Value = parameterValue.Value.ToString()
                    };

                    report.Parameters.Add(par);
                    report.Uri = $"Reports/{reportId}.trdp";
                }
            }

            return report;
        }
    }
}

 

90 % of the time, we can render reports without issue. However, there are times where any report that uses a SQL connection seems to be unable to reach our primary database. EF Core (which interacts with the same DB prior to and after rendering reports) seems to never have this issue - even when Telerik does. Both share the exact same connection string. Rendering a report with an included SQL query returns something like the following: 

On occasion, this issue seems to resolve itself after ~5 minutes. Most of time, we need to kill the container instance and restart it a number of times before reports render without issue. I'm confounded why this happens - it 'feels' like the underlying SQL connection is reused.

Any help is appreciated - this has been a critical issue to our clients, we can't keep using this reporting solution without a fix.

Todor
Telerik team
 answered on 27 Mar 2024
1 answer
89 views

Good morning.

I wanted to address an issue we're running into while trying to post a .Net Core / Angular app with a folder of standalone reports. For some unknown reason these will work fine on my machine, I have a couple dozen built from the Telerik Reporting standalone designer, but it won't work on an Azure VM.

The need to set up an Azure VM occurred to me when I realized that I couldn't update a SQL connection for a report unless the connection returns as valid, which in this case it's a private SQL resource so they set us up with a VM to momentarily upload the reports and edit them from the same internal domain as the SQL server. The problem I'm running into now is that we get the following error, seemingly unconditoinally, from the Azure VM environment:

Connection unsuccessful. Check the connection string and try again. Details: Expecting a non-empty string for 'providerInvariantName' parameter.

That error comes back even if we add providerInvariantName to the string. Something else is clearly going on, I don't exactly know what but it seems like it's an environment issue with the Azure VM if no changes to the sql string either cause a different error or succeed.

What I'd like to ask for is more insight into what kinds of things can cause this error so we understand the problem space a bit better. Please let us know your thoughts on what we need to look at in order to troubleshoot this.

Dimitar
Telerik team
 answered on 27 Feb 2024
1 answer
26 views

I created a report using Telerik Report Designer Standalone with sqlDataSource1 setup with the following ReportParameters like this:



C# coded that read that send the parameter as Int32

    var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
    // set any deviceInfo settings if necessary
    var deviceInfo = new System.Collections.Hashtable();
    var reportSource = new Telerik.Reporting.UriReportSource();
    var directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
    var value = Convert.ToInt32(numericExportarPdf.Value);
    reportSource.Uri = "Report.trdp";
    reportSource.Parameters.Add("NRO_TICKET", value);
    Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);
    if (result.HasErrors) return;
    string fileName = result.DocumentName + "." + result.Extension;
    string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
    string filePath = Path.Combine(path, fileName);
    using FileStream fs = new FileStream(filePath, FileMode.Create);
    fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);

I get the following error:

Telerik.Reporting.Processing.CancelProcessingException: An error has occurred while processing the report. Processing canceled. Check the InnerException for more information.
 ---> System.Exception: Invalid value of report parameter 'NRO_TICKET'.
   --- End of inner exception stack trace ---
   at Telerik.Reporting.Processing.Report.ValidateParameters()
   at Telerik.Reporting.Processing.Report.ProcessItem()
   at Telerik.Reporting.Processing.ReportItemBase.ProcessElement()
   at Telerik.Reporting.Processing.Report.ProcessElement()
   at Telerik.Reporting.Processing.ProcessingElement.Process(IDataMember dataContext)
   at Telerik.Reporting.Processing.Report.Process(Boolean processItemActions, Boolean documentMapEnabled)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReport(Report report, IPathResolver pathResolver, IProcessingContext parentContext, IEnumerable`1 parameters, Key rootKey, Boolean interactivityEnabled, Boolean documentMapEnabled, PageLayoutInfo pageSettings, ErrorEventHandler errorHandler, List`1 documentNodes, Boolean& documentMapAvailable)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessResolvedReports(ResolvedReportDocument resolvedReportDocument, IList`1 parameters, IProcessingContext contextPerDocument, Boolean interactivityEnabled, Boolean documentMapEnabled, PageLayoutInfo pageSettings, List`1 processedReports, ErrorEventHandler errorHandler, List`1 documentNodes, Boolean& documentMapAvailable, ListSlice& tocReportsSlice)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReportSource(ReportSource reportSource, IRenderingContext context)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReportSource(ReportSource reportSource, Hashtable deviceInfo, IRenderingContext context)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRender(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRenderStateless(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.<>c__DisplayClass47_0.<RenderReport>b__0(SingleStreamManager sm)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReportSafe(Func`2 renderCallback, String format, IRenderingContext renderingContext)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo, CancellationToken cancellationToken)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo)

If I remove the parameter the report works fine, I added changing to Decimal Type value as my DB engine is MS-SQL 2022 Express. I added filters and get same error. I don't know what to do anymore What I am missing

1 answer
134 views
how to use AM PM date format in textbox
n/a
Top achievements
Rank 1
Iron
 answered on 13 Feb 2024
1 answer
83 views

Currently, we use SSRS in our ASP.NET MVC apps to automatically generate tabular, in-memory reports based on RDLC templates against SQL Server data. The PDF produced by SSRS are downloaded to the user's browser. We don't provide any report viewer components on the page. How do you do this using Telerik Reporting?

Also, do you have beginner training videos for Telerik Reporting?

Thank you.

Dimitar
Telerik team
 answered on 26 Dec 2023
0 answers
19 views

Good Afternoon Telerik,

I am trying to narrow my report results on a DateTime value for an entire month of results. due to it being a schedule some of the times will go into the next day (in example: 11:00 PM 11/02 Thursday to 7:00 AM 11/03 Friday) However, when I run the report. It is only showing times for 7:00 AM to 11:00 PM that night. it reversed the entry instead of it going from 11:00 PM first day to 7:00 AM next day. Is there anyway for me to fix this?

Austin
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 05 Dec 2023
1 answer
112 views

Hi, I have stored procedure which is splitted on 2 parts.

CREATE PROCEDURE dbo.MyProcedure
@ReportPart smallint
AS
IF @ReportPart = 0
BEGIN
SELECT ColumnPart0Id, ColumnPart0Name, ColumnPart0Code
FROM Table
END
ELSE IF @ReportPart = 1
BEGIN
SELECT ColumnPart1Address, ColumnPart1PostCode, ColumnPart1Contractor
FROM Table
END


When I execute procedure in Telerik Report Designer (SQL Data Source) with

EXEC dbo.MyProcedure
@ReportPart = 0

everything is ok, but after execute query

EXEC dbo.MyProcedure
@ReportPart = 1

I have error "Can't setup column 'ColumnPart0Name'. This value violates limit MaxLength of this column".

It's weird because in @ReportPart = 1 there isn't any column name like ColumnPart0Name, it exists in first "IF" .

Is it bug?

Query works fine in SSMS.

 

Wojciech
Top achievements
Rank 1
Iron
 answered on 18 Oct 2023
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?