regarding pass DateTime Parameter

Stimulsoft Reports.WEB discussion
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

regarding pass DateTime Parameter

Post 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
Attachments
EmpLateComePerDay.mrt
(27.38 KiB) Downloaded 360 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: regarding pass DateTime Parameter

Post 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.
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: regarding pass DateTime Parameter

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: regarding pass DateTime Parameter

Post 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.
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: regarding pass DateTime Parameter

Post 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
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: regarding pass DateTime Parameter

Post by m.issa »

Hello

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

thank you
Attachments
SampleData.rar
(106.57 KiB) Downloaded 377 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: regarding pass DateTime Parameter

Post 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.
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: regarding pass DateTime Parameter

Post 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
Attachments
ImamU.rar
(144.73 KiB) Downloaded 244 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: regarding pass DateTime Parameter

Post by Alex K. »

Hello,

Please check the sample report in attachment.

Thank you.
Attachments
Capture.PNG
Capture.PNG (57.22 KiB) Viewed 5493 times
ReportSample.mrt
(8.46 KiB) Downloaded 679 times
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: regarding pass DateTime Parameter

Post 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
Post Reply