Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 9th, 2006, 12:00 PM
Authorized User
 
Join Date: Mar 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Record selection formula and export to pdf

hi guys.
could you please help me with this
i have problem setting the RecordSelectionFormula and exporting to pdf.for some reason it doesn't take/set the record selection formula. but if do with the web viewer,instead of pdf it works fine. i am lost please help.
here is the code below.

Dim myreport As New ReportDocument
Dim UserId, Password, ServerName, DatabaseName As String

 Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  InitializeComponent()
  myreport.Load("C:\Crystal\qwert.rpt")
  UserId = "aaa"
  Password = "bbb"
  ServerName = "ccc"
  DatabaseName = "dddd"
  LogonToDatabase(myreport, UserId, Password, ServerName, DatabaseName)
  myreport.DataDefinition.RecordSelectionFormula = "{CLIENT.USERID} in ['ABC']"
  PrintToPdfWithStream(myreport)

 End Sub


 Public Shared Sub LogonToDatabase(ByVal MyReport As CrystalDecisions.CrystalReports.Engine.ReportDocum ent, ByVal UserId As String, ByVal Password As String, Optional ByVal ServerName As String = "", Optional ByVal DatabaseName As String = "")
     Dim MyTable As CrystalDecisions.CrystalReports.Engine.Table
     Dim MyConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
     Dim MyLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo
     If ServerName <> "" Then
         MyConnectionInfo.ServerName = ServerName
         MyConnectionInfo.DatabaseName = DatabaseName
     End If
     MyConnectionInfo.UserID = UserId
     MyConnectionInfo.Password = Password
     MyLogonInfo.ConnectionInfo = MyConnectionInfo
     For Each MyTable In MyReport.Database.Tables
         MyTable.ApplyLogOnInfo(MyLogonInfo)
     Next
End Sub


 Public Sub PrintToPdfWithStream(ByVal MyReport As CrystalDecisions.CrystalReports.Engine.ReportDocum ent)
        Dim MyExportOptions As New CrystalDecisions.Shared.ExportOptions
        MyExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
        Dim MyExportRequestContext As New CrystalDecisions.Shared.ExportRequestContext
        MyExportRequestContext.ExportInfo = MyExportOptions
        Dim MyStream As System.IO.Stream
        MyStream = MyReport.FormatEngine.ExportToStream(MyExportReque stContext)
        Response.ClearHeaders()
        Response.ClearContent()
        Response.ContentType = "application/pdf"
        Dim MyBuffer(MyStream.Length) As Byte
        MyStream.Read(MyBuffer, 0, CType(MyStream.Length, Integer))
        Response.BinaryWrite(MyBuffer)
        Response.End()

 End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
export to pdf nilsan ASP.NET 1.0 and 1.1 Professional 0 February 21st, 2007 06:24 AM
Subreport with formula selection ceema Crystal Reports 1 April 12th, 2006 02:41 AM
Record selection Rijaz BOOK: Professional Crystal Reports for VS.NET 0 April 24th, 2005 08:59 AM
Record selectionf formula for date Bhavin Crystal Reports 0 December 9th, 2004 11:17 AM
Export to .pdf bgottschall Crystal Reports 1 July 21st, 2004 06:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.