Page 1 of 1

Using Parameters in DataSource query

Posted: Fri Mar 16, 2018 1:40 pm
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

Re: Using Parameters in DataSource query

Posted: Mon Mar 19, 2018 2:43 am
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

Re: Using Parameters in DataSource query

Posted: Mon Mar 19, 2018 12:21 pm
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.

Re: Using Parameters in DataSource query

Posted: Tue Mar 20, 2018 9:52 am
by JackC23
This can be ignored now.

I was using LookUpBox.SelectedValue instead of SelectedItem. It is working now.

Re: Using Parameters in DataSource query

Posted: Tue Mar 20, 2018 1:37 pm
by Edward
Hi Jack,

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

Thank you,
Edward