2014-04-12 75 views
1

我有一个MS Access数据库,在某些表中有超过1000行。水晶报告有时是空白的

这是我的代码。

在按钮上单击事件:它正在创建该文件夹并将其中所有pdfs放在其中。只有超出数字7的pdf是空的(不显示数据,但显示设计文本对象)。而主表1适配器的详细信息部分仅显示数据集的第一行。表示它不做它应该这样做。数据集有数据(它显示预览数据)。

我也多次验证这个数据库。也测试过连接。所以我不确定发生了什么问题。水晶报告版本是包含视觉工作室2008的版本。

请帮忙。

道德提振评论是最受欢迎的,因为我一直坚持这个为期3天。 。:(

Dim i As Integer 
Dim locnoreq As String 
Dim secreq As Integer 
Dim zonereq = pszone.Text 
Dim ps As String 

Dim ds As New DataSet1() 
Dim foldername As String 
foldername = zonereq.Substring(0, 2) 
'MsgBox(foldername) 
Dim ExportFolder As String = Application.StartupPath + "\" + foldername 
If Not IO.Directory.Exists(ExportFolder) Then 
    IO.Directory.CreateDirectory(ExportFolder) 
End If 
'Dim locnoreq = psloc.SelectedValue 
'Dim xx = psloc.SelectedIndex + 1 
For i = 0 To psloc.Items.Count - 1 
    Dim rpt As New CrystalReport1() 
    psloc.SelectedIndex = i 
    filldata() 'fills sector no(lblsector) label 
    filldata1() 'modifies textbox 18 ps value 
    'MsgBox(lblsector.Text) 
    locnoreq = psloc.Text 
    secreq = CType(lblsector.Text(), Integer) 
    ps = TextBox18.Text 

    'MsgBox(zonereq & "zonereq pszone") 
    'MsgBox(secreq & "secreq lblsector") 
    'MsgBox(locnoreq & "psloc") 
    'MsgBox(ps & "textbox18") 
    Dim main_adapter As New OleDbDataAdapter("select Sectt_No,AC_No,PS_No,PS_Name,PA_Assigned,PS_Location,M,F,Total,Nature,PP1,CRPF,Bus_No from MainTable where AC_No='" & zonereq & "'and PS_Location='" & locnoreq & "'", con1) 
    main_adapter.Fill(ds, "MainTable") 
    main_adapter.Dispose() 
    Dim zones_adapter As New OleDbDataAdapter("select Magistrate,Magistrate_No,ZonalOfficer,ZonalOfficer_No from Zones where AC_No='" & zonereq & "'", con1) 
    zones_adapter.Fill(ds, "Zones") 
    zones_adapter.Dispose() 

    Dim location_adapter As New OleDbDataAdapter("select CPMF,CPMF_No,Lady_Worker,Police_Station,Sections from Location where AC_No='" & zonereq & "' and PS_Location='" & locnoreq & "'", con1) 
    location_adapter.Fill(ds, "Location") 
    location_adapter.Dispose() 
    Dim ps_adapter As New OleDbDataAdapter("select Zonal_SP,Zonal_SP_No,SDPO,SDPO_No,SHO,SHO_No from pstable where Police_Station='" & ps & "'", con1) 
    ps_adapter.Fill(ds, "pstable") 
    ps_adapter.Dispose() 
    Dim sectors_adapter As New OleDbDataAdapter("select Sectt_Mag,Sectt_Mag_No,Sectt_Off,Sectt_Off_No from sectors where AC_No='" & zonereq & "' and Sectt_No=" & secreq & "", con1) 
    sectors_adapter.Fill(ds, "sectors") 
    sectors_adapter.Dispose() 
    Dim main1_adapter As New OleDbDataAdapter("select PS_No,PS_Name,PA_Assigned,M,F,Total,PP1,Bus_No from MainTable where AC_No='" & zonereq & "'and PS_Location='" & locnoreq & "'order by ID asc", con1) 
    main1_adapter.Fill(ds, "MainTable1") 
    main1_adapter.Dispose() 
    rpt.SetDataSource(ds) 
    Dim frm2 As New Form2 
    frm2.CrystalReportViewer1.ReportSource = rpt 

    'rpt.ExportOptions.DestinationOptions = Application.StartupPath + "\" + foldername + "\" + i + 1 + ".pdf" 
    'rpt.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile 
    'rpt.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat 

    ''Export the report 
    'rpt.Export() 
    rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Application.StartupPath & "\" & foldername & "\" & i + 1 & ".pdf") 
    frm2.CrystalReportViewer1.Dispose() 
    frm2.Close() 
    rpt.Refresh() 
    rpt.Close() 
    rpt.Dispose() 

    ds.Clear() 
    clear() 

Next 
MsgBox("Done") 

回答

0

分辨!!! 的问题是设置在我的数据的联系我删除了一些,并保持其他的(某种暴力的东西:d),和它的工作fine.Though我不知道如何。