C#Crystal Report详细循环

时间:2016-05-30 06:23:08

标签: c# .net winforms crystal-reports

我在关于c#winform crystal report的报告中有这个循环。

enter image description here 数据重复输入到我的报告中,但是当我检查数据库时,它只保存了一次。考虑最终值是正确的。

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);
            }

1 个答案:

答案 0 :(得分:0)

您正在查询某些字段但未显示。

请放入报告student_info.LName字段。

你看到了什么?有很多学生的收据吗?这是你需要的吗?

运行查询到数据库。你得到了什么结果?