2016-05-30 9 views
0

私はこのループをC#winform crystal reportのレポートに載せています。C#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); 
      } 
+0

リンクテーブルはありますか?それは複数の重複を引き起こす可能性があります – KuKeC

+0

あなたは** ID **の接続を意味しますか?..私のテーブルを次にリンクする必要がありますか?または削除しますか? –

+0

テーブルからリンクを削除し、出力を確認する必要があります。私は2つのテーブルに間違った結合をしたときにいくつかの同様の問題がありました。 – KuKeC

答えて

0

照会しているが表示されていないフィールドがあります。

student_info.LNameフィールドにご記入ください。

あなたは何を見ますか?多くの学生にレセプションがありますか?これはあなたが必要とするものですか?


DBに対してクエリを実行します。あなたが得た結果は何ですか?

+0

不完全なスクリーンショットです。 student.info.Lname/Fname '(student_info.IDno = collection_type.IDno)に参加しました。 –

+0

" ls fee 1 "の隣にstudent_info.LNameを追加してください。あなたは何を見ますか?必要な学生または多くの学生だけ? –

+0

私はDBに私のクエリを実行する、私はそれが何をしたいと私はそれが欲しいものを見た。だから、私のクエリに間違っている –

関連する問題