2
Answers

Binding a reportviewer to sql datareader

Gary Sanford

Gary Sanford

13y
5.3k
1
I created a report using a binding source and dataset using the wizard.  The report runs ok.
I want to change the bindingsource to a dataset that I create.
this is my code:
            SqlConnection sqlconn = new SqlConnection(connStr);
            string rptwhere = " select * from MTA_WIP where CustID='009'";
            System.Data.DataTable jdtl = new System.Data.DataTable();
            SqlDataAdapter jdtla = new SqlDataAdapter(rptwhere, sqlconn);
            DataSet jdtls = new DataSet();
            try
            {
                int idtlcount = jdtla.Fill(jdtls);
            }
            catch (SqlException)
            {
            }
            jdtl = jdtls.Tables[0];
            this.MTA_WIPBindingSource.DataSource = jdtl;
            this.reportViewer1.RefreshReport();

I'm not getting any errors but I'm not getting any data on the report either.
I can step through each line and see that I am getting 31 rows of data in jdtl as I should but I get a blank report.
What am I doing wrong?
thanks,
Answers (2)