Guys,
Can you help me how to debug my codes, I was stuck and i can't find the error why there's no data appeared when i export on pdf file.
DSData as my DATASET
DTR_Report as my Crystal REport
here's my code:
DataOpen()
cmd.CommandText = "Select BIOID, afpsn, Dept, Lname, Fname, CONVERT(char(10), date, 101)Date, Day, AM_IN, AM_OUT, PM_IN, PM_OUT, OT_IN, OT_OUT, DeptHead, DeptPost, TimeLate from AllDTR where BIOID = '" & users & "' AND Date > '08/31/2009' ORDER BY Date"
da = New SqlClient.SqlDataAdapter(cmd.CommandText, cmd.Connection)
ds = New DSDTR
da.Fill(ds, "PrintDTR")
cmd.Connection.Close()
Dim rpt As New ReportDocument
rpt.Load(Server.MapPath("CrystalReports/DTR_Report.rpt"))
rpt.SetDataSource(ds)
Dim expOption As ExportOptions
Dim destination As DiskFileDestinationOptions
Dim Fname As String
Fname = Server.MapPath("App_Data/Temp/" & Session.SessionID.ToString & ".pdf")
destination = New DiskFileDestinationOptions()
destination.DiskFileName = Fname
expOption = rpt.ExportOptions
With expOption
.DestinationOptions = destination
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
rpt.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(Fname)
Loading

Dharmesh SharmaRank #1,974 · 741 reputationPosted Oct 29, 2009, 10:46 PM EDT
Mac Punsalang3 reputationPosted Oct 29, 2009, 10:50 PM EDT
Thanks your help, but i have a hard time translating C# into VB.net. If you have VB.net code to transfer the crystal report into pdf file.
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Oct 30, 2009, 4:13 AM EDT
What's your requirement? Or the problem? Is the report not exported to pdf with your code?
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Oct 30, 2009, 4:17 AM EDT
If it's the problem, I have a simple working sample for you.
reportDocument1.Load("C:\Report1.rpt") Dim dOpt As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions() Dim eO As CrystalDecisions.Shared.ExportOptions eO = reportDocument1.ExportOptions With eO .ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile .ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat End With dOpt.DiskFileName = "C:\\test.pdf" eO.DestinationOptions = dOpt reportDocument1.Export(eO)If your problem is something else let us know.