Page 1 of 1

Master Detail parameter with SQL Server

Posted: Sat Jun 27, 2020 3:25 pm
by lutin7812
Hi, I'm trying to make a simple Master Detail Report works with SQL Server.
I've copied the SQLMasterDetail.mrt that works with MSACCESS to run it with SQL Server.
But when I preview the report I get the error: scalar variable "@CategoryID" must be declared.

Master query datasource 'Categories' is:

Code: Select all

SELECT * FROM Categories
Detail query 'Sales_By_Categories' datasource is:

Code: Select all

SELECT * FROM [Products] where CategoryID = @CategoryID
I've declared the

Code: Select all

@CategoryID int 
parameter in the detail datasource to match the PK column of the master datasource.

Any idea on how the master - detail link with parameter should be made to work with SQL Server?
Thank's for help.
Olivier

Re: Master Detail parameter with SQL Server

Posted: Sat Jun 27, 2020 5:17 pm
by lutin7812
I found the problem: you must specify in the detail datasource parameter expression, the name of Master column name key eg. MaterTtable.PkColumnName.

Re: Master Detail parameter with SQL Server

Posted: Sun Jun 28, 2020 8:50 am
by Andrew
Hello,

Thank you for sharing your solution.