regarding pass DateTime Parameter
regarding pass DateTime Parameter
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
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 361 times
Re: regarding pass DateTime Parameter
Hello.
Please, try to use next code:
Thank you.
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;
Re: regarding pass DateTime Parameter
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
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
Hello.
Then try to use next query with DateTime variable:If there is still a problem then send us a sample data for your report.
Thank you.
Then try to use next query with DateTime variable:
Code: Select all
select * from ViewEmpSummary where SsmDate = {ParamDate}
Thank you.
Re: regarding pass DateTime Parameter
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
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
Hello
please find in the attachment compressed file contains a sample data with two reports files.
thank you
please find in the attachment compressed file contains a sample data with two reports files.
thank you
- Attachments
-
- SampleData.rar
- (106.57 KiB) Downloaded 378 times
Re: regarding pass DateTime Parameter
Hello.
To avoid asking the variable value you should disable the Request From User property of the variable.
Thank you.
There is not enough data in your database backup for your reports.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 )
To avoid asking the variable value you should disable the Request From User property of the variable.
Thank you.
Re: regarding pass DateTime Parameter
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
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 245 times
Re: regarding pass DateTime Parameter
Hello,
Please check the sample report in attachment.
Thank you.
Please check the sample report in attachment.
Thank you.
- Attachments
-
- Capture.PNG (57.22 KiB) Viewed 5500 times
-
- ReportSample.mrt
- (8.46 KiB) Downloaded 680 times
Re: regarding pass DateTime Parameter
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
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