I created a report using the Standalone Designer (in .trdp
format). In the data connection, I configured it to use a shared connection. From within the Designer, everything works fine — I can preview and export to PDF without any issues.
I then created a console project (code shown below) to try exporting the report to PDF.
In the project's configuration file, I added a connection string to use.
However, when executing the following line:
RenderingResult result = reportProcessor.RenderReport("PDF", sourceReportSource, deviceInfo);
I get an error in the Inner Exception:
Keyword not supported: 'host'.
My PostgreSQL connection string is:"Host=localhost;Port=5432;Database=crp;Username=postgres;Password=****"
But the connection string is correct — it’s exactly the same one I use in the Standalone Designer, where it works without any problem.
If I embed the connection string directly in the report instead of using a shared connection, everything works fine.
Any idea what could be causing this?
static void Main(string[] args)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
IConfiguration config = builder.Build();
string connectionString = config.GetConnectionString("crp");
string reportName = @"D:\dev\telerik-reporting\reports\report.trdp";
var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
// set any deviceInfo settings if necessary
var deviceInfo = new System.Collections.Hashtable();
var sourceReportSource = new Telerik.Reporting.UriReportSource();
sourceReportSource.Uri = reportName;
sourceReportSource.Parameters.Add("procedure_id", 6);
RenderingResult result = reportProcessor.RenderReport("PDF", sourceReportSource, deviceInfo);
if (!result.HasErrors)
{
//string fileName = result.DocumentName + "." + result.Extension;
string fileName = "file.pdf";
string path = @"D:\";
//string path = System.IO.Path.GetTempPath();
string filePath = System.IO.Path.Combine(path, fileName);
using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
}
}