vb 水晶报表出现重复数据
sql语句为:
Private Sub Form_Load()
Dim CRYAT As New CRAXDRT.Application
Dim CRY As CRAXDRT.Report
Dim Strcnn As String
Dim cnn1 As New ADODB.Connection
Dim adoRS As New ADODB.Recordset
cnn1.ConnectionString = "Provider=sqloledb;Data Source=10.90.2.71;Initial Catalog=cabcis;User Id=sa;Password=1111;"
cnn1.Open
adoRS.CursorLocation = adUseClient
adoRS.Open "SELECT DISTINCT a.a_1310, a.a_1550, a.tube_serial_no,a.serial_no,a.coloring, b.len_con, b.cable_type ,a.coef_pmd, b.drum_no FROM cable_fiber as a INNER JOIN final_cab_main as b ON a.sheath_no = b.sheath_no WHERE b.sheath_no='" & Trim(cable_tube.Text2.Text) & "' order by a.tube_serial_no,serial_no ", cnn1, adOpenDynamic, adLockOptimistic
Set CRYAT = New CRAXDRT.Application
Set CRY = CRYAT.OpenReport(App.Path & "\report2.rpt ")
Call CRY.Database.Tables(1).SetDataSource(adoRS)
Call CRY.Database.Tables(2).SetDataSource(adoRS)
CRY.DiscardSavedData
CRViewer91.ReportSource = CRY
CRViewer91.Refresh
CRViewer91.ViewReport
End Sub
在数据库下单独运行 没有出现重复,但在报表中就重复了。比如正常查询结果是12条,但报表重复的条数是144条,不知问题在哪儿,希望能帮忙分析一下
[解决办法]
Call CRY.Database.Tables(1).SetDataSource(adoRS)
'Call CRY.Database.Tables(2).SetDataSource(adoRS) 没这么用过,这个去掉看看