Click here to Skip to main content
15,916,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one table called DailyReport which has a column DateInput(date when data has been written in the DailyReport table). Each day data is written in, and I am in need of having a report generated by dates, so I have placed two datetimepicker controls on my report but I can't get the code to help me open report by desired dates checked by those datetimepicker controls.
Any help with the code? I have checked the articles here and Google, but I am still in a jam.
Thanks!
Posted
Updated 30-Jan-11 20:56pm
v2
Comments
Abhinav S 31-Jan-11 1:44am    
What sort of jam are you in? Are you getting some errors?
shonezi 31-Jan-11 3:51am    
I just can't get fill adapter to work for the table to generate report when I choose date in those two datetime controls because those datetime controls are not bound to the table. I am new to C# but eager to learn, I have a report, two datetime controls, one button, a table with primary column DateInput with dates, and I want when I choose dates and click on the button to generate report only for choose dates. I know I have to put some code in SQL for the report but I don't know how because those datetime controls are not part of the table

1 solution

Steps:
1. Get the 'To' date and 'From' date from the datepicker controls.
2. These dates are parameters to the query that will fetch data. Now query can be part of report or query data directly can be used in report
3. In query:
SQL
SELECT * FROM DailyReport WHERE DateInput BETWEEN @FromDate AND @ToDate


This query would return you the needed data. Use the data in your report and display it.
 
Share this answer
 
Comments
shonezi 31-Jan-11 4:57am    
I did this but when I click on finish I get error in WHERE clause near '@', so when I try preview data I get nothing, no parameters
Sandeep Mewara 31-Jan-11 5:00am    
'@' signifies parameters.

Either use the query in SP or parameterized query.
shonezi 31-Jan-11 5:14am    
forgive me for asking but what does that mean to use query in SP or parameterized query???
Sandeep Mewara 31-Jan-11 5:27am    
Not an issue. Tell me, how do you run a query OR get data for your report? Whats the procedure and the place you try to get data from?
shonezi 31-Jan-11 5:41am    
ok1.I have table DailyReport
2.Dataset1 in which query is:


SELECT RB, Bankomat, DateInput, FROM DailyReport
WHERE DateInput BETWEEN @FromDate AND @ToDate

3. I use this Dataset1 for making Report1.rdlc which I use for reportviewer for generating report
4. above reportviewer is 2 dateTimePickers, one from and other to date, and the Button for generating report when I choose dates
5. in Button is code: private void button1_Click(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'DataSet1.DailyReport' table. You can move, or remove it, as needed.
this.DailyReportTableAdapter.Fill(this.DataSet1.DailyReport);

this.reportViewer1.RefreshReport();


I hope I have explained a little better how it looks like, I am quite new, but as I said , trying to learn :))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900