First Create an DataSet file(.XSD). Then create DataTable(dt) with fields the same as bs and the assign bs with dt . after that dt appears in DataSource of your Report you can select any fields of that. maybe this link can help you http://www.mindstick.com/Articles/13169999-ef3b-496c-b502-caef973c3bb2/?Using%20ReportViewer%20in%20WinForms%20C
How to show data in a table in report viewer
-
11-06-2023 - |
Question
I want to get data from sql server (with custom query and connection string) and use tha data to fill a table in report viewer
here is my code to fill a DataGridView, I want something like this:
MyDB db = new MyDB();//class that contains my sql connection
string sql = "SELECT * FROM factoritem WHERE fid='{0}'";
sql = string.Format(sql, _fid);//_fid is a identity that it's value has been set before
SqlDataAdapter sda = new SqlDataAdapter(sql, db.MyConn);
DataSet ds = new DataSet();
BindingSource bs = new BindingSource();
sda.Fill(ds);
bs.DataSource = ds.Tables[0].DefaultView;
DGV_FactorItem.DataSource = bs;
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow