Showing posts with label datareader. Show all posts
Showing posts with label datareader. Show all posts

Wednesday, March 7, 2012

How can i group data returned by a datareader by a particular field

How can i group the data returned by statement below by "Dept" field. I have already tried to group it like shown below but that doesn't seem to work for me. Any help.

cmd_select =

New SqlCommand("SELECT Incident_id,Dept From Report_Incident Group By Dept,Incident_id", myconnection_string)

Try using ORDER BY instead of GROUP BY in the SQL. That should work.

|||Ok thanks ORDER BY should work but the problem is that i want to display the returned data visually in a pie chart. Eg if i have three departments(Dept) in Administratio, Engineering and Production, then my chart should only show those three not to show the dept for each and every record. So basically i want to group the piechart slices by dept.|||

Ok i got it. The code below now does my work.

cmd_select =New SqlCommand("SELECT COUNT(incident_id)AS total ,Dept,incident_date From Report_Incident

WHERE incident_date >=@.date1 AND incident_date<=@.date2 GROUP BY dept,incident_date ORDER BY total", myconnection_string)

Friday, February 24, 2012

How can i get data from DataReader Destination?

Hi:

I am a beginner at SSIS subjects, i have a data stored at DataReader Destination and i want continue working whit the data. Somebody can help me?

Regards. deniscuba

What exactly do you want to do with the data?

Why have you used a datareader destination?

If you really do want to use the data made available from the datareader destination then perhaps this article will help: http://msdn2.microsoft.com/zh-cn/library/ms135917.aspx

-Jamie

|||

DataReader Destination
(http://msdn2.microsoft.com/en-us/library/ms140291(SQL.90).aspx)

Loading the Output of a Package
(http://msdn2.microsoft.com/en-us/library/ms135917.aspx)

Defining Datasets for Package Data from SQL Server Integration Services
(http://msdn2.microsoft.com/en-us/library/ms159215.aspx)

Normally you would use DtsClient (see Loading the Output of a Package above). You can also write your own consumer if you really wanted to, for example I have written a managed provider, so we can chain packages together, package 1 terminates in a DataReader Destination, package 2 starts with a DataReader Source that is pointed at the package 1. Not something you would normally do, but it suits our requirements.