简体   繁体   中英

C# Crystal Report detail loop

I have this loop on my report on c# winform crystal report.

在此处输入图片说明 The data repeatedly entered on my report, but when I check on the database it only saved once. Consider that the final value is correct.

try
            {
                Cursor = Cursors.WaitCursor;

                Reports.OfficialReceipt crt = new Reports.OfficialReceipt();


                cmd = new MySqlCommand();
                MySqlDataAdapter myDA = new MySqlDataAdapter();
                DataSet DaTs = new DataSet();

                con = new MySqlConnection(cs);
                cmd.Connection = con;


                cmd.CommandText = "SELECT collection_type.collection_id, collection_type.school_year, collection_type.IDno, collection_type.student_org_desc, collection_type.man_org, collection_type.grand_total, collection_type.tendered_cash, collection_type.payment_change, collection_type.collection_date, student_info.FName, student_info.LName, accounts.name, collection_list.detail, collection_list.unit, collection_list.amount FROM collection_type JOIN collection_list on (collection_type.collection_id = collection_list.collection_id) JOIN accounts on (accounts.id = collection_type.account_id) JOIN student_info on (student_info.IDno = collection_type.IDno) WHERE collection_type.IDno='" + txtIDNo_Collection.Text + "'";
                cmd.CommandType = CommandType.Text;
                myDA.SelectCommand = cmd;
                myDA.Fill(DaTs, "collection_type");
                myDA.Fill(DaTs, "student_info");
                myDA.Fill(DaTs, "accounts");
                myDA.Fill(DaTs, "collection_list");
                crt.SetDataSource(DaTs);

                Reports.frmSampleForm frm = new Reports.frmSampleForm();
                frm.crystalReportViewer1.ReportSource = crt;
                frm.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

There are some fields that you're querying but not showing.

Please drop in the report student_info.LName field.

What do you see? Are there reciepts for many students? Is this what you need?


Run you query to a DB. What is the result you get?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM