Blazor - set connectionstring dynamically

Stimulsoft Reports.Web discussion
Post Reply
Jose
Posts: 5
Joined: Thu Oct 17, 2019 8:42 am

Blazor - set connectionstring dynamically

Post by Jose »

Hi!

In MVC:
string connstr = GetStimulsoftConnString(something);
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new StiSqlDatabase("MS SQL", connstr));
"MS SQL" is datasource in the Myreport.mrt.

How can I do this in Blazor? (error: StiSqlDatabase couldn't be found)

Thanks

Attila
Max Shamanov
Posts: 201
Joined: Tue Sep 07, 2021 10:11 am

Re: Blazor - set connectionstring dynamically

Post by Max Shamanov »

Hello,

We couldn't reproduce the issue.
Please send us a sample project that reproduces the issue.

Thank you.
Jose
Posts: 5
Joined: Thu Oct 17, 2019 8:42 am

Re: Blazor - set connectionstring dynamically

Post by Jose »

Hi Max!

I figured out a solution.
I have a request: 3173721 I send the project a few days ago.
If you insert these 3 lines (bold, italic - Set connectionstring), then you get the problem:

//Load report template
report.Load("Pages/BlazorReport.mrt");

// Set connectionstring
string connstr = "Data Source=PC\\INSTANCE1;Initial Catalog=DatabaseName;Integrated Security=False;Persist Security Info=True;User ID=usern;Password=passw;Connect Timeout=100";
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new StiSqlDatabase("MS SQL", connstr));


//Render, w/out showing progress
report.Render(false);

Error: StiSqlDatabase could not be found.

In the mrt report, I set a connectionstring, but I have much database and I must set the appropriate one in the program.

Attila
Max Shamanov
Posts: 201
Joined: Tue Sep 07, 2021 10:11 am

Re: Blazor - set connectionstring dynamically

Post by Max Shamanov »

Hello,

Add

Code: Select all

@using Stimulsoft.Report.Dictionary
in your project.

Thank you.
Jose
Posts: 5
Joined: Thu Oct 17, 2019 8:42 am

Re: Blazor - set connectionstring dynamically

Post by Jose »

Hi Max!

It's amazing. It works fine now. Thank you very much.

------------------------
I have another problem - I hope this is the last one for now.
Export to Html is OK.
Export to Pdf is not.
I set the text font in the report mrt to Cuorier New.

Error: Exception in PdfFonts.GetFontMetrics, font 'Courier New' step #10: 'Object reference not set to an instance of an object.'
2 lines:
- StiReportResponse.ResponseAsPdf(report);
- report.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, _exportFilePath);

Why is that? (I need this feature very much.)

Thanks

Attila
Post Reply