Help Please - Opening a report using a URL

Stimulsoft Reports.WEB discussion
Post Reply
sdms2020
Posts: 5
Joined: Wed Aug 12, 2020 9:45 am

Help Please - Opening a report using a URL

Post by sdms2020 »

Firstly I would like to say I am totally new to Stimulsoft reports. I am seeking assistance from anyone who can advise me what I need to do (my skill level - basic). I will break this up into two parts, (1) what I would like to achieve and (2) what I have done so far. Hopefully someone will then be able to tell me exactly what I need to do to to get this to work. I have searched the forums, the online documentation for a step by step guide or video and also contacted support on three occasions but support have said they don't understand what I want. They have given me links to Git and posts in the forum but as I mentioned I am new to this and really would appreciate some real basic guidance from someone who has actually done this so I can purchase a license and move forward.
(1) What I would like to achieve is to open a report using a URL which has a parameter in the URL so that the report only displays data pertaining to the parameter in the URL. I don't want a user to be able to select anything from the report viewer so thats why I am wanting to open the report through a URL.
(2) What I have done so far: I have downloaded and installed Stimulsoft-Reports.Web-2020.3.2. I. I have created a basic report which uses a MSSQL view for its data source. Under dictionary I have added a variable called schoolID with Type = int, Value = Value, Int by = Value, Allow using as SQL parameter = ticked and for Value I have left this empty. The parameter appears to work fine in that if I enter 1 for value and preview the report then only data for SchoolID = 1 displays on the report. If I manually change this from 1 to 3 then only data for SchoolID = 3 displays on the report. I have then published the report to my dev computer with the platform ASP.NET selected which produces a Show-TestProject-AspNet-Pack.zip. I extracted the files then used Visual Studio to open the sln file. After opening the sln in VS I built it then selected the IIS Express button which opens the report without issue. I opened up a web browser and entered the following URL: http://localhost:55459/Default.aspx?sti ... schoolID=1. The report opens but no data is displayed in the report.
Its my understanding that to open the report and pass the parameter to the report I have to place some code in a file within the published project. What I don't know is what that code is and what file it has to be placed in or where in the file it is to be placed. In the root of the project that VS created I have a default.aspx file - is this the file that the code has to be placed in? I would really appreciate it if someone had a code snippet that I can use to achieve this, advise me of anything I have to alter or adjust for in the code snippet and where do I put this piece of code.
Steve
Lech Kulikowski
Posts: 7339
Joined: Tue Mar 20, 2018 5:34 am

Re: Help Please - Opening a report using a URL

Post by Lech Kulikowski »

Hello,

To set variables value, you can use the following code:
report["paramName"] = "value";

To get it from URL, please check the msdn documentation or
https://stackoverflow.com/questions/659 ... ing-in-net

Thank you.
sdms2020
Posts: 5
Joined: Wed Aug 12, 2020 9:45 am

Re: Help Please - Opening a report using a URL

Post by sdms2020 »

Hi Lech

I went to the URL you posted. So is the code that I need just these two lines below? and if so what file do I put them in.
Uri myUri = new Uri("http://www.example.com?param1=good&param2=bad");
string param1 = HttpUtility.ParseQueryString(myUri.Query).Get("param1");

Thank you.
Lech Kulikowski
Posts: 7339
Joined: Tue Mar 20, 2018 5:34 am

Re: Help Please - Opening a report using a URL

Post by Lech Kulikowski »

Hello,

Please take a look at a simple example of how to use parameters in a report taken from a URL. Run the project and set the parameters in the URL - for example, such as these:
http://localhost:51101/Default.aspx?nam ... name=Smith.

The project can be downloaded here:
https://drive.google.com/file/d/1vHK4O7 ... sp=sharing

Thank you.
sdms2020
Posts: 5
Joined: Wed Aug 12, 2020 9:45 am

Re: Help Please - Opening a report using a URL

Post by sdms2020 »

Lech
Thank you, I finally got this to work.
Lech Kulikowski
Posts: 7339
Joined: Tue Mar 20, 2018 5:34 am

Re: Help Please - Opening a report using a URL

Post by Lech Kulikowski »

Hello,

You are welcome!
Post Reply