我有一个MS Access数据库,在某些表中有超过1000行。
这是我的代码。
按钮点击事件:它正在创建文件夹并将所有pdfs
放入其中。只有7号以上的pdf为空(不显示数据,但显示设计文本对象)。而主表1适配器的详细信息部分仅显示第一行数据集。不做它应该做的事情。数据集有数据(显示预览数据)。
我还多次验证了数据库。也测试了连接。所以我不确定出了什么问题。水晶报告版是包含visual studio 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 :(得分:0)
分辨!!! 问题在于我的数据集中的链接。我删除了一些并保留了其他的(某种蛮力的东西:D),它工作得很好。虽然我不知道如何。