Page 1 of 1

The ConnectionString property has not been initialized error when i use stimulsoft report in asp.net

Posted: Wed Apr 24, 2019 9:29 am
by dorsa2
I have a Stimulsoft report. and now I want to use this report in asp.net.when I call my report in the local mode it works truly in my system and didn't have any problem. but when I publish my web form and change the connection string of my code to server address and run it in my local computer it worked true but when I upload it I faced to below error:

The ConnectionString property has not been initialized.
Image

this is my code that calls my report:

Code: Select all

LblCourseId.Text = Request.QueryString["CourseId"];
 
        string ConnectionString = ConfigurationManager.ConnectionStrings["KDUIS-v1ConnectionString"].ConnectionString;
        string ServerLocation = HttpContext.Current.Server.MapPath(string.Empty);
        StiReport MyStiReport = new StiReport();
        MyStiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", ConnectionString));
        MyStiReport.Load(ServerLocation + "\\Report\\AttendanceList.mrt");
        MyStiReport.Dictionary.Variables["CourseId"].Value = LblCourseId.Text;
 
        StiWebViewer1.Report = MyStiReport;
and the current connection string that I used for the published site is:

Code: Select all

<add name="KDUIS-v1ConnectionString" connectionString="Data Source=address of my site ;Initial Catalog= my db ;Persist Security Info=True;User ID=username ;Password= password " providerName="System.Data.SqlClient" />
I have searched through the Forum but couldn't find a way to do it. Many Thanks in advance.

Re: The ConnectionString property has not been initialized error when i use stimulsoft report in asp.net

Posted: Thu Apr 25, 2019 9:00 pm
by Lech Kulikowski
Hello,

Your code is wrong, the added database is overloaded after load report.
Please try to use:
((StiSqlDatabase)report.Dictionary.Databases[ "ConnectionName"]).ConnectionString = ConnectionString;

Thank you.

Re: The ConnectionString property has not been initialized error when i use stimulsoft report in asp.net

Posted: Sat Apr 27, 2019 6:04 am
by dorsa2
Lech Kulikowski wrote: Thu Apr 25, 2019 9:00 pm Hello,

Your code is wrong, the added database is overloaded after load report.
Please try to use:
((StiSqlDatabase)report.Dictionary.Databases[ "ConnectionName"]).ConnectionString = ConnectionString;

Thank you.
thx dear Lech Kulikowski,
I modified the code as you said, but it doesn't knows StiSqlDatabase parameter.

Re: The ConnectionString property has not been initialized error when i use stimulsoft report in asp.net

Posted: Mon Apr 29, 2019 7:04 am
by Lech Kulikowski
Hello,

Please send us a sample project which reproduces the issue for analysis.

Thank you.