Page 1 of 2

regarding pass DateTime Parameter

Posted: Sat Sep 08, 2012 12:29 pm
by m.issa
Hello all

How can I pass date parameter into my report which has my SQL query inside it?
The following is my try to do that:
Note: the type of SsmDate field inside my database is: DateTime.
- My query inside the report is : select * from ViewEmpSummary where Convert(varchar(12),SsmDate, 103) = {ParamDate}
// this function Convert(varchar(12),SsmDate, 103) is to convert SsmDate from DateTime to string in this format : “dd/MM/yyyy”
- I declared variable under the name (ParamDate) with string type.

- The following is my C# code to pass the datetime value from there to the report query :
StiReport report = new StiReport();
report.LoadFromString(a);
report.Render();
report["ParamDate"] = “05/09/2012”;
report.Render();
StiWebViewerFx1.Report = report;

But this generated this error in stimulsoft environment: Incorrect syntax near ‘=’

Also I tried to declare the variable in DateTime type, but this generated this error:
Incorrect syntac near ‘3’
3 is the hours in DateTime format in stimulsoft environment because when I chose the DateTime format when I declared the variable, this format come with it: (09/08/2012; 03:15:14)

Please find my report in the attachment incase of something not clear.

Thank in advanced

Re: regarding pass DateTime Parameter

Posted: Mon Sep 10, 2012 7:53 am
by HighAley
Hello.
Please, try to use next code:

Code: Select all

        StiReport report = new StiReport();
        report.LoadFromString(a);
        report.Compile();
        report["ParamDate"] = “05/09/2012”;
        report.Render();
        StiWebViewerFx1.Report = report;
Thank you.

Re: regarding pass DateTime Parameter

Posted: Mon Sep 10, 2012 12:43 pm
by m.issa
Dear Aleksey

thank you for your reply, i tried to add this line ( report.Compile(); ) before passing the parameter, after that the report run without the previous error that i wrote in my previous message, but the report show all records, even if i pass date have no records in my data base, so is there another suggestion, because i think the value of the date parameter does not pass properly.

thank you

Re: regarding pass DateTime Parameter

Posted: Mon Sep 10, 2012 1:13 pm
by HighAley
Hello.

Then try to use next query with DateTime variable:

Code: Select all

select * from ViewEmpSummary where SsmDate = {ParamDate}
If there is still a problem then send us a sample data for your report.

Thank you.

Re: regarding pass DateTime Parameter

Posted: Mon Sep 10, 2012 1:22 pm
by m.issa
hello

it is working if i create the query with Date Time variable, but the problem after the report display, the report ask again to enter the date parameter, it is create text box in the header and ask to enter the date parameter, then it show the data properly, but i want pass the parameter before display the report not after.
this is just happen if write my query like this: select * from ViewEmpSummary where SsmDate = @ParamDate, and i declare @ParamDate Parameter as Date Time and declare ParamDate Variable as Date Time.

but if i write my query like this : select * from ViewEmpSummary where SsmDate = {ParamDate} and even if i declare the variable ParamDate as Date Time i still get this error: Incorrect syntac near ‘3’ because the Date Time format in stimulsoft come with time (09/10/2012; 03:33:57 )

i will prepare sample data as you asked.

thank you

Re: regarding pass DateTime Parameter

Posted: Mon Sep 10, 2012 1:59 pm
by m.issa
Hello

please find in the attachment compressed file contains a sample data with two reports files.

thank you

Re: regarding pass DateTime Parameter

Posted: Tue Sep 11, 2012 8:06 am
by HighAley
Hello.
m.issa wrote:it is working if i create the query with Date Time variable, but the problem after the report display, the report ask again to enter the date parameter, it is create text box in the header and ask to enter the date parameter, then it show the data properly, but i want pass the parameter before display the report not after.
this is just happen if write my query like this: select * from ViewEmpSummary where SsmDate = @ParamDate, and i declare @ParamDate Parameter as Date Time and declare ParamDate Variable as Date Time.

but if i write my query like this : select * from ViewEmpSummary where SsmDate = {ParamDate} and even if i declare the variable ParamDate as Date Time i still get this error: Incorrect syntac near ‘3’ because the Date Time format in stimulsoft come with time (09/10/2012; 03:33:57 )
There is not enough data in your database backup for your reports.
To avoid asking the variable value you should disable the Request From User property of the variable.

Thank you.

Re: regarding pass DateTime Parameter

Posted: Tue Sep 11, 2012 11:34 am
by m.issa
Hello

i disabled the Request From User property of the variable, it did not ask me to enter the Date when the report display, but the old problem still exist which is displaying all date, if i choose date has records or if i choose date has no records in data base, in all cases it is displaying records in the report viewer.

please find the another data base in the attachment, and please use nVerification and nEnrollment Tables in your test, because these two tables have many records especially nVerification table.

thank you

Re: regarding pass DateTime Parameter

Posted: Wed Sep 12, 2012 9:01 am
by Alex K.
Hello,

Please check the sample report in attachment.

Thank you.

Re: regarding pass DateTime Parameter

Posted: Wed Sep 12, 2012 1:56 pm
by m.issa
Hello Aleksey

i would like to tell you that i downloaded your sample report, i followed everything and now every thing working properly, although yesterday i did every step exactly but it did not work yesterday, i dont know how this problem solved but however at least everything working properly.

i would like to thank you for your valuable time and your support that you gave me until this problem solved.

best regards