Passing parameters value for query table not work
I'm trying pass parameter value for query table in fastreport.net, but this not work. I've try all possibilites. The fastreport open, but not show results. Somebody can help me?
My code in C#:
Report r = new Report();
r.Load(Path.Combine(Environment.CurrentDirectory + @\relatorios\usuarios\horaextra\ + ltbModelo.SelectedItem));
r.SetParameterValue("ID", 2);
r.Show();
My query in fast report:
SELECT
NOME,
SEC_TO_TIME(SUM(TIME_TO_SEC(HE.HORAEXTRA))) as TOTAL_HORA
FROM TUSUHORAEXTRA HE
LEFT OUTER JOIN TUSUUSUARIO US ON (HE.ID_USUARIO = US.IDUSUARIO)
WHERE HE.ID_USUARIO = @ID
GROUP BY NOME
Parameter properties:
(Name) = @ID
DataType = Int
DefaultValue = 2
Expression =
Size = 1
More details in attachments
My database is MySQL
My code in C#:
Report r = new Report();
r.Load(Path.Combine(Environment.CurrentDirectory + @\relatorios\usuarios\horaextra\ + ltbModelo.SelectedItem));
r.SetParameterValue("ID", 2);
r.Show();
My query in fast report:
SELECT
NOME,
SEC_TO_TIME(SUM(TIME_TO_SEC(HE.HORAEXTRA))) as TOTAL_HORA
FROM TUSUHORAEXTRA HE
LEFT OUTER JOIN TUSUUSUARIO US ON (HE.ID_USUARIO = US.IDUSUARIO)
WHERE HE.ID_USUARIO = @ID
GROUP BY NOME
Parameter properties:
(Name) = @ID
DataType = Int
DefaultValue = 2
Expression =
Size = 1
More details in attachments
My database is MySQL
This discussion has been closed.
Comments
Hello!
Close all instances of Visual Studio.
In the Data window, create a report parameter (under Parameters -> New Parameter):
Name: ID
DataType: System.Int32
Open the query parameter settings for your table in the Query Wizard (leave WHERE HE.ID_USUARIO = @ID in the SQL text) and check the parameter properties:
Name: ID (without the @ symbol)
DataType: Int32 (or Int)
Expression: [ID] (reference to the report parameter in square brackets)
Size: 0 (the Size property is used for string types; do not set it to 1 for integers).
In the C# code, pass the value before displaying or generating the report:
using (Report r = new Report()) { r.Load(Path.Combine(Environment.CurrentDirectory, “relatorios”, ‘usuarios’, “horaextra”, ltbModelo.SelectedItem.ToString())); r.SetParameterValue(“ID”, 2); r.Show(); }