|
-
Mar 25th, 2010, 07:54 PM
#1
Thread Starter
Addicted Member
VbNet2008 Crystal Report 9 problem
-
May 17th, 2013, 09:29 AM
#2
New Member
Re: VbNet2008 Crystal Report 9 problem
I am using code like the following to view Crystal Reports from .Net
Public Class Form1
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim oApp = New CRAXDRT.Application
Dim oReport As CRAXDRT.Report
oReport = oApp.OpenReport("C:\temp\reportname.R01.rpt", 1)
With oReport.Database.Tables(1).ConnectionProperties
.DeleteAll()
.Add("Provider", "SQLOLEDB.1")
.Add("User ID", "UserName")
.Add("Password", "Password")
.Add("Initial Catalog", "Database")
.Add("DSN", "DSNName")
End With
AxCrystalActiveXReportViewer1.ReportSource = oReport
AxCrystalActiveXReportViewer1.ViewReport()
End Sub
Private Sub AxCrystalActiveXReportViewer1_Enter(sender As System.Object, e As System.EventArgs) Handles AxCrystalActiveXReportViewer1.Enter
End Sub
End Class
-
Nov 19th, 2014, 10:14 AM
#3
New Member
Re: VbNet2008 Crystal Report 9 problem
Try:
Imports CrystalDecisions
Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Dim RptDoc As New ReportDocument()
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim crtableLogoninfo As New TableLogOnInfo
RptDoc.Load(Server.MapPath(Request.ApplicationPath + "/Reports/myReport.rpt"))
With crConnectionInfo
.ServerName = "myServer"
.DatabaseName = "myDatabase"
.UserID = "myUserID"
.Password = "myPassword"
End With
CrTables = RptDoc.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
RptDoc.SetDatabaseLogon(crConnectionInfo.UserID, crConnectionInfo.Password, crConnectionInfo.ServerName, crConnectionInfo.ServerName)
RptDoc.SetParameterValue("@myParameter", myValue)
Dim stream As New BinaryReader(RptDoc.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", Convert.ToString("attachment; filename=") & myDownloadAsFilename)
Response.AddHeader("content-length", stream.BaseStream.Length.ToString())
Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)))
Response.Flush()
Response.Close()
-
Nov 19th, 2014, 02:16 PM
#4
Re: VbNet2008 Crystal Report 9 problem
I don't think you should be using AxCrystalActiveReportViewer in VB .Net. You should be using CrystalReportViewer component for VB .Net. Read this http://scn.sap.com/thread/2131910
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|