问题:如何删除水晶报表中的重复数据及其原因是什么?
这是我的代码
Dim rpt As New PendingRequest
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 request_number,asset_name, asset_type, asset_price, asset_quantity, tbl_asset_maintenance.supplier_code, supplier_name , reason_to_buy from tbl_asset_request join tbl_asset_maintenance on tbl_asset_request.asset_number = tbl_asset_maintenance.asset_number left join tbl_supplier on tbl_asset_maintenance.supplier_code = tbl_supplier.supplier_code left join tbl_account_group on tbl_asset_maintenance.group_code = tbl_account_group.group_code where asset_request_num = " & account_payable_form.req_num & " order by request_number"
con.Open()
cmd.CommandType = CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "tbl_asset_request")
da.Fill(ds, "tbl_asset_maintenance")
da.Fill(ds, "tbl_supplier")
da.Fill(ds, "tbl_account_group")
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
答案 0 :(得分:1)
我已经阅读了您的问题,其原因在您的“加入您的命令”文本中, 您要确定此处需要LEFT联接或内部联接需要的每个表...
答案 1 :(得分:0)
从tbl_asset_request tas,tbl_asset_maintenance tam,tbl_supplier ts,tbl_asset_group_t 标签哪里tas.asset_number = tam.asset_number和tam.supplier_code = ts.supplier_code和tam.group_code = tag.group_code,其中asset_request_num =“&account_payable_form.req_num&”按request_number排序“
在命令文本中尝试此操作并查看结果。