Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Printing through Crystal to PDF
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Printing through Crystal to PDF
Divers
Thread ID:
00927708
Message ID:
00927708
Vues:
56
Hi everyone!

I am trying to print orders and invoices from my ASP.NET application to a printer connected to my local PC. I am using SQL server 2000 as the database. I have the following code from a tutorial which gets me part way there...
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnPrint.Click
		Dim crReportDocument As ReportDocument
		Dim crExportOptions As ExportOptions
		Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
		Dim TempFileName As String
		Dim Order As New Samatason.CustomerOrder
		Dim dsOrder As DataSet
		Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
		Dim crLogin As CrystalDecisions.Shared.TableLogOnInfo

		dsOrder = Customer.GetOrderByOrderID(CType(Request("OrderID"), Integer))
		If IsNothing(dsOrder) Then
			Dim ex As New Samatason.Exceptions.SQLServerRetrieveException
			lblAlert.Text = ex.Message
			tblAlert.Visible = True
			Exit Sub
		End If

		crReportDocument = New ReportDocument
		crReportDocument.Load("D:\websites\windowswebs\rptorder.rpt")

		For Each crTable In crReportDocument.Database.Tables
			crLogin = crTable.LogOnInfo
			crLogin.ConnectionInfo.UserID = "User"
			crLogin.ConnectionInfo.Password = "pass"
			crTable.ApplyLogOnInfo(crLogin)
		Next

		crReportDocument.SetDataSource(dsOrder)

		TempFileName = "d:\vsdotnet\reports\" & Session.SessionID.ToString & ".pdf"

		crDiskFileDestinationOptions = New DiskFileDestinationOptions
		crDiskFileDestinationOptions.DiskFileName = TempFileName
		crExportOptions = crReportDocument.ExportOptions

		With crExportOptions
			.DestinationOptions = crDiskFileDestinationOptions
			.ExportDestinationType = ExportDestinationType.DiskFile
			.ExportFormatType = ExportFormatType.PortableDocFormat
		End With

		crReportDocument.Export()
		Response.ClearContent()
		Response.ClearHeaders()
		Response.ContentType = "application/pdf"
		Response.WriteFile(TempFileName)
		Response.Flush()
		Response.Close()
		System.IO.File.Delete(TempFileName)

	End Sub
At the moment rptorder.rpt is a blank report but I want it to print one order from the orders table.

If I open the report and use the database expert to connect to the database and place the fields I want on the report, I get back all the records in the orders table on my report!

What I would really like is to use the dataset I prepare in code. Is this possible and if so how?

Many thanks...
Chris Maiden
Email
Web
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform