Passing parameter to a report from a program

I followed this


I am trying to pass a parameter from a program.


I made the Parameter

Made the DB connection

select * from TableName where ID =?

Added the main report paramter into the SQL parameter expression label

When I hit next it gives me a Incorrect syntax near '?'

Comments

  • What is your version of FR?

    What database do you use?

  • Assign parameter with report's variable in the parameter's editor. Pass variable to report

    frxReport1.Variables.Variables['YourNumVariableName'] := 123;

    frxReport1.Variables.Variables['YourStringVariableName'] := '''' + 'test' + '''';

  • the error says that you can not send and add parametre to sql. Please check your fastreport sql in which you should add YourNumVariableName property

  • Hello!

    The correct approach in FastReport .NET:

    In the data source's SQL query, enter: SELECT * FROM TableName WHERE ID = @CustomerId.

    In the SQL parameter editor, bind @CustomerId to the report parameter [CustomerId] (with the appropriate data type, such as Int32).

    From the C# code, pass the value after report.Load(...) and before report.Prepare():

    report.Load(“report.frx”);
    report.SetParameterValue(“CustomerId”, 777);
    report.Prepare();
    
This discussion has been closed.