Blazor - set connectionstring dynamically
Blazor - set connectionstring dynamically
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
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
-
- Posts: 522
- Joined: Tue Sep 07, 2021 10:11 am
Re: Blazor - set connectionstring dynamically
Hello,
We couldn't reproduce the issue.
Please send us a sample project that reproduces the issue.
Thank you.
We couldn't reproduce the issue.
Please send us a sample project that reproduces the issue.
Thank you.
Re: Blazor - set connectionstring dynamically
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
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
-
- Posts: 522
- Joined: Tue Sep 07, 2021 10:11 am
Re: Blazor - set connectionstring dynamically
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
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
-
- Posts: 522
- Joined: Tue Sep 07, 2021 10:11 am
Re: Blazor - set connectionstring dynamically
Hello,
The AddFontFile() method does not modify the report.
It just adds a font file to a special collection and makes it accessible to our tool.
The PDF format is a fixed-layout format and all fonts should be the same.
So you see the issue in PDF only.
If you use Courier New font in your report, you need to load this font with StiFontCollection.AddFontFile(path, "Courier New") to export it in PDF without error.
Thank you.
The AddFontFile() method does not modify the report.
It just adds a font file to a special collection and makes it accessible to our tool.
The PDF format is a fixed-layout format and all fonts should be the same.
So you see the issue in PDF only.
If you use Courier New font in your report, you need to load this font with StiFontCollection.AddFontFile(path, "Courier New") to export it in PDF without error.
Thank you.
Re: Blazor - set connectionstring dynamically
Hi!
OK.
I blowed it - copying fonts to my folder.
It works now.
Sorry.
Regards
Attila
OK.
I blowed it - copying fonts to my folder.
It works now.
Sorry.
Regards
Attila
-
- Posts: 522
- Joined: Tue Sep 07, 2021 10:11 am
Re: Blazor - set connectionstring dynamically
Hello,
You are welcome!
You are welcome!