Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Question sir,

I'm creating a report using crystal report in vs 2012 and I have this problem. The data in my reports are duplicating while the concatenated field is now showing? I don't know where the problem. Please help.
C#

Dim rpt As New Active_Assets

        Dim con As New MySqlConnection
        Dim cmd As New MySqlCommand
        Dim da As New MySqlDataAdapter
        Dim ds As New DataSet("DataSet1")




        Try
            con = New MySqlConnection("server=localhost;userid=root;password=123456;database=asset_db")
            cmd.Connection = con
            cmd.CommandText = "SELECT asset_info.asset_code, booking_date, asset_name, asset_amount, asset_info.department_code, asset_info.group_code,asset_info.supplier_code, employee_code, business_unit_code,supplier_name,group_name,  concat(min(months_left), ' MONTHS')  FROM asset_info join tbl_account_group on asset_info.group_code = tbl_account_group.group_code join tbl_department on asset_info.department_code = tbl_department.department_code join tbl_supplier on asset_info.supplier_code = tbl_supplier.supplier_code join tbl_depreciation on asset_info.asset_code = tbl_depreciation.asset_code where asset_status = 'ACTIVE' group by asset_info.asset_code order by asset_number "
            con.Open()
            cmd.CommandType = CommandType.Text
            da.SelectCommand = cmd
            da.Fill(ds, "asset_info")
            da.Fill(ds, "tbl_employee")
            da.Fill(ds, "tbl_supplier")
            da.Fill(ds, "tbl_department")
            da.Fill(ds, "tbl_accout_group")
            da.Fill(ds, "tbl_depreciation")
            rpt.SetDatabaseLogon("root", "123456")
            rpt.Database.Tables(0).SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rpt
            con.Close()

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            con.Dispose()
        End Try
Posted
Updated 29-Sep-14 5:55am
v3
Comments
Abdul Samad KP 30-Sep-14 1:30am    
Why you are filling dataset multiple times?
Migs.0 1-Oct-14 7:14am    
cause the fields that im using for my crystal report is in different tables.
Abdul Samad KP 1-Oct-14 10:41am    
Since you are not changing your command text, you will have same data and schema in all tables
Migs.0 1-Oct-14 10:56am    
question sir, how can i fill different table in my dataset using that particular query^?
Migs.0 1-Oct-14 20:45pm    
Thank you, sir. I've realize my mistake. I solved my own problem. Thank you. :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900