Using Parameters in DataSource query

Stimulsoft Reports.NET discussion
Post Reply
JackC23
Posts: 5
Joined: Thu Mar 08, 2018 4:52 pm

Using Parameters in DataSource query

Post by JackC23 »

I have a parameter '@YearDropDown' that takes it's value from a LookUpBox.SelectedValue

I then use @YearDropDown in the following SQL statement in a DataSource.

Code: Select all

SELECT
	LD.Description,
	ST.StartDate,
	ST.EndDate
FROM
	SchoolTerms ST
LEFT JOIN
	LookupDetails LD ON ST.Name = LD.LookupDetailsID AND LD.LookupID = '2200'
WHERE 
	ST.SchoolYear = @YearDropDown
ORDER BY
	ST.Name DESC
When clicking preview the following error message is displayed:

The parameterized query '(@YearDropDown int)SELECT
LD.Description,
ST.StartDate,
ST' expects the parameter '@YearDropDown', which was not supplied.

Any help or being pointed in the right direction would be great.

I read the documentation in the following link https://www.stimulsoft.com/en/documenta ... meters.htm
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Using Parameters in DataSource query

Post by Edward »

Hi Jack,

Please check the following topic about use the LookUpBox:
viewtopic.php?&t=253

and for the parameters, please try to use the following approach, which should be easier:
https://www.youtube.com/watch?v=OARslvYADBI

And if you need some help with your report, please feel free to attach the report template (mrt file) to this topic.

Thank you,
Edward
JackC23
Posts: 5
Joined: Thu Mar 08, 2018 4:52 pm

Re: Using Parameters in DataSource query

Post by JackC23 »

Hi Edward,

Thanks for the help.

I have attached the report in question.

In Form1 the first LookUpBox is populating correctly with from my table 'SchoolTerms'.

I want the second LookUpBox to populate upon the first LookupBox having an option selected.

I am currently getting the error 'Object reference not set to an instance of an object.' When selecting an option from the first LookUpBox.
Attachments
sstA655.mrt
(63.14 KiB) Downloaded 185 times
JackC23
Posts: 5
Joined: Thu Mar 08, 2018 4:52 pm

Re: Using Parameters in DataSource query

Post by JackC23 »

This can be ignored now.

I was using LookUpBox.SelectedValue instead of SelectedItem. It is working now.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Using Parameters in DataSource query

Post by Edward »

Hi Jack,

No problem, please let us know if you need any help.

Thank you,
Edward
Post Reply