Connect to database C#

Stimulsoft Ultimate discussion
Post Reply
semaphore
Posts: 19
Joined: Fri Jul 24, 2020 12:53 pm

Connect to database C#

Post by semaphore »

Good Day,

I am attempting to connect to the database via C# code like:
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new StiSqlDatabase("Connection", _configuration.GetConnectionString("ConnString")));
When attempting to run my report no data is returning, however when I embed the exact same connection string within the report itself and run the report from my code the data is returned. It appears that the connection string is not being used when passing it via the code method, I am using 2020.5.1 and will only be upgraded to the later version at the end of the year, early next.

Please advise what could be going wrong.
semaphore
Posts: 19
Joined: Fri Jul 24, 2020 12:53 pm

Re: Connect to database C#

Post by semaphore »

I was able to resolve it myself, it turned out that inside the report the connection to the DB was aliased as SQL, in code I was using the string Connection. It appears the software is unable to infer a connection properly. Either way its resovled.
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Connect to database C#

Post by Lech Kulikowski »

Hello,

Thank you for the information.
Post Reply