Page 1 of 1
Code based variables won't show their value while running..
Posted: Wed Nov 27, 2013 5:26 pm
by theregister
I´m losing my mind here, I've tried every example I've found online and still can't get it to work, this is the way im creating the variables on the code that generates the report:
Code: Select all
report.Dictionary.Variables.Add(New Stimulsoft.Report.Dictionary.StiVariable("test",""))
report("test") = "ANYTHING"
While it does show me the created variables on the gui, they contain absolutely nothing, any ideas on what I'm doing wrong? Thanks!
Re: Code based variables won't show their value while runnin
Posted: Thu Nov 28, 2013 6:17 am
by Alex K.
Hello,
Please try to use the following code:
Code: Select all
report.Dictionary.Variables("test").Value = "ANYTHING"
Thank you.
Re: Code based variables won't show their value while runnin
Posted: Thu Nov 28, 2013 6:05 pm
by theregister
And it works! Who would've thought lol. Thanks though, I have another question regarding this same thing, now that we managed to set an actual value for this variable, can this value be something else? I'm thinking about SQL code, so I can use a variable instead of a query while running the program, is this possible?
Re: Code based variables won't show their value while runnin
Posted: Fri Nov 29, 2013 6:19 am
by Alex K.
Hello,
You can use the variable in SQL query:
for example: select * from Table where Column = {Variable}
Aslo you can set the sql command from code:
Code: Select all
((StiSqlSource)report.Dictionary.DataSources["DataSourceName"]).SqlCommand = newSqlCommand;
Thank you.
Re: Code based variables won't show their value while runnin
Posted: Fri Nov 29, 2013 7:24 pm
by theregister
Let's see I tried with a simple query and it worked, but I have 2 other doubts..
First, can I use variables inside of variables? I'll explain.. let's say I have this in a databand:
and {query} contains this:
and {value} contains 5 for example.
When I try to set the whole query in the databand, I cannot retrieve the columns and it gives me the next error:
I can put the value of {value} by myself, and it will retrieve the columns, but when I preview the report it will give me the same Incorrect syntax error.. so is there another way to do this?
And the second doubt, when I use variables that contain SQL code like we're doing here, is there any way to execute them outside of a databand? Say I want to run a specific query but I want the result of the query, a single value, to be shown on a single text label at the top of the report, but I don't want to specify a whole databand just for that one value, can this be done as well?
Thanks a lot for your support.

Re: Code based variables won't show their value while runnin
Posted: Tue Dec 03, 2013 7:50 am
by Alex K.
Hello,
Can you please send us your report which reproduce the issue for analysis.
Thank you.