-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: lacisum
Message 2 in Discussion

Hi,        This is the sample code what u have asked for    Imports 
CrystalDecisions.CrystalReports.Engine 
Imports CrystalDecisions.Shared 
Imports CrystalDecisions.Web.Design  Public Class WebForm1 
Inherits System.Web.UI.Page 
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer  
#Region " Web Form Designer Generated Code "  'This call is required by the Web Form 
Designer. 
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()  End Sub  
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles MyBase.Init 
'CODEGEN: This method call is required by the Web Form Designer 
'Do not modify it using the code editor. 
InitializeComponent() 
End Sub  #End Region  Private Sub CreateReport(ByVal sReport As String, ByVal 
sReportFormula As String) 
' passes report location i.e c:\inetpub\wwwroot\report.rpt 
' report custom formula i.e {Table.Field1}>1200 
' displays report in browser (temp.pdf)  Dim exportOpts As New ExportOptions() 
Dim oRpt As New ReportDocument()  Dim diskOpts As New DiskFileDestinationOptions() 
'load report 
oRpt.Load(sReport)  'log on to SQL server  Dim crLogonInfo As 
CrystalDecisions.Shared.TableLogOnInfo 
crLogonInfo = oRpt.Database.Tables(0).LogOnInfo 
crLogonInfo.ConnectionInfo.ServerName = "ServerName" 
crLogonInfo.ConnectionInfo.UserID = "UserName" 
crLogonInfo.ConnectionInfo.Password = "Password" 
crLogonInfo.ConnectionInfo.DatabaseName = "DatabaseName" 
oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)  'export report to viewer PDF 
exportOpts = oRpt.ExportOptions 
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile 
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat ' 
ExportFormatType.WordForWindows, ExportFormatType.Excel other formats 
'temp file name 
diskOpts.DiskFileName = "temp\temp.pdf" 
exportOpts.DestinationOptions = diskOpts  Dim ReportFields As FormulaFieldDefinitions 
= oRpt.DataDefinition.FormulaFields()  oRpt.RecordSelectionFormula = 
oRpt.RecordSelectionFormula + sReportFormula ' existing formula + custom 
' or parameter i.e oRpt.DataDefinition.ParameterFields("Parameter1") = "1" 
Try 
oRpt.Export() 
Response.Redirect("temp.pdf") 
Catch 
'could not create report 
'label1.text="Check your ......." 
End Try 
End Sub  End Class      I will also give you a good link which will help in guiding 
you in working with crystal report with .net    http://www.crystalreportsbook.com   
Regards Raghu Chakkath http://licasum.blogspot.com

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to