Question rdlc: Bar Chart Dataset query

dualshck012

Active member
Joined
Jan 14, 2018
Messages
29
Location
Leyte, Philippines
Programming Experience
1-3
Good Day!
Need help on SQL query for my rdlc reporting file in visual studio. I have a BAR chart which displays the total patient collections but my chart displays all the data in specific dates and not according to group dates or any relevant term to say. The screenshot below tells the problem at dates 2/25/2018 which should’ve been merged in one bar for the total patient in that date.

see attached image
BAR-Chart.png

Here is the script from the query builder in Visual Studio 2015:

SELECT COUNT(*) AS total_exam, labcollect AS collected
FROM labinpat
WHERE (labcollect BETWEEN ? AND ?)
GROUP BY labcollect


I think I’m missing a query after GROUP BY labcollect . I tried GROUP BY CONVERT(labcollect) / CAST(labcollect AS DATE) but return as error.

IDE: VS2015
Database: MySQL through ODBC
 
The issue appears to be that you are grouping by a column that contains both date and time when you want the data grouped by date only. Instead of using `labcollect`, you need to use just the date component of `labcollect`. I don't really use MySQL so I don't know what function it uses to get just the date from a date/time but that should be fairly simple to find out. Let's say, for argument's sake, that it is `GETDATE(labcollect)`. You need to use that in both your SELECT and GROUP BY clauses.
 
SELECT COUNT(*) AS total_exam, DATE(labcollect) AS collecteddate
FROM labinpat
WHERE (labcollect BETWEEN ? AND ?)
GROUP BY DATE(labcollect)

I just tried this one but an error appear afterwards:

Error: sql execution error.

Error[07002][MySQL][ODBC 3.51 Driver][mysql-5.0.45-community-nt]SQLBindParameter not used for all parameters

BUT this one works fine but doesnt get the result I wanted:

SELECT COUNT(*) AS total_exam, labcollect AS collecteddate
FROM labinpat
WHERE (labcollect BETWEEN ? AND ?)
GROUP BY labcollect
 
I don't really use MySQL I'm afraid. That first option would work for SQL Server, which is what I use pretty much all the time. Maybe you need to do some research on the database you're using. For one thing, you have an error code. Did you search for information on that?
 
Populating a dataset and passing to report sir.

I have this in my code:
labcolltableadapter.Fill(lablogsheet.Labcoll, _fromdtp1.value, _todtp1.value);
reportviewer2.RefreshReport();

I have parameters in dataset Labcoll:
Fill,GetData(labcollect, labcollect1)
 
Back
Top Bottom