---
title: "passing dataset to report viewer"  
description: "passing dataset to report viewer"  
author: "Ahmed Algosaibi"  
published: 2013-04-17  
updated: 2013-05-02  
canonical: https://www.mindstick.com/forum/780/passing-dataset-to-report-viewer  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# passing dataset to report viewer

Hello guys,\
I've [windows app](https://www.mindstick.com/services/windows-development) that uses [report viewer](https://www.mindstick.com/forum/406/how-to-view-reports-in-c-sharp-using-microsoft-report-viewer), but the [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) that I don't get result back?\
\
This is my code.\
\
[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void Form3_Load(object sender, EventArgs e)\
{\
con.ConnectionString = connection.x;\
\
runRptViewer();\
}\
\
private [DataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) getData()\
{\
\
con.Open();\
DataSet1 dss = new DataSet1();\
[string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) sql = "select product_id, product_name,product_quantity from [product](https://www.mindstick.com/articles/75385/full-product-keys)";\
[SqlDataAdapter](https://www.mindstick.com/interview/33991/what-is-sqldataadapter) da = new SqlDataAdapter(sql, con);\
da.Fill(dss);\
DataTable dt = dss.Tables["product"];\
\
return dt;\
}\
\
private void runRptViewer()\
{ \
reportViewer1.LocalReport.DataSources.Clear(); //clear report\
reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc"; // bind reportviewer with .rdlc\
Microsoft.Reporting.WinForms.ReportDataSource [dataset](https://www.mindstick.com/articles/19/dataset) = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", getData()); // set the [datasource](https://www.mindstick.com/blog/447/listing-the-databases-connected-to-the-datasource)\
reportViewer1.LocalReport.DataSources.Add(dataset);\
reportViewer1.LocalReport.Refresh();\
reportViewer1.RefreshReport();\
}

## Replies

### Reply by Chris Anderson

you can visit this link, this will clearly explain you how to use report viewer:\
\
http://www.mindstick.com/Articles/13169999-ef3b-496c-b502-caef973c3bb2/?Using%20ReportViewer%20in%20WinForms%20C\


---

Original Source: https://www.mindstick.com/forum/780/passing-dataset-to-report-viewer

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
