Y
Y
Yuri Denisov2014-06-09 05:35:14
C++ / C#
Yuri Denisov, 2014-06-09 05:35:14

How to populate Microsoft Reports programmatically?

Good afternoon! Such a problem. I am making a report in the visual editor of the Report Wizard, there you need to specify the connection string so as not to burn the password, it is removed from the connection string. After creation, naturally does not connect. I'm trying to take all the data from the database and specify the report on a new one, but it doesn't work, just a white page and inactive controls. Help with code?

string comm = "здесь мой запрос, удалил его т.к. длинный";
 MySqlConnection conn = new MySqlConnection("server=адрес сервера;User Id=юзер;password=пароль;Persist Security Info=True;database=имя бд");
            MySqlCommand comd = new MySqlCommand(comm, conn);
            DataTable print2DataSet2 = new DataTable();
            conn.Open();
            print2DataSet print2DataSet = new print2DataSet();
            MySqlDataAdapter cardsTableAdapter = new MySqlDataAdapter(comd);
            this.cardsTableAdapter.Fill(this.print2DataSet.cards, id_card_for_print);
            conn.Close();
            
           
            this.reportViewer1.Reset();

            this.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
           ReportDataSource rptSrc = new ReportDataSource("print2DataSet2", cardsTableAdapter);
            this.reportViewer1.LocalReport.DataSources.Add(rptSrc);
        
            this.reportViewer1.RefreshReport();

In visual mode, everything is set like this
c0148cafca4442749761d628ca9370ee.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Kryuchek, 2016-10-18
@denissov

You need to separately create a dataset and transfer it there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question