Results 1 to 4 of 4

Thread: VbNet2008 Crystal Report 9 problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2010
    Location
    New Zealand
    Posts
    207

    VbNet2008 Crystal Report 9 problem

    Hi Good Guys,
    I need your help. Please help me.

    While developing VBNet2008 Window Application to automate Crystal Report printing I encountered this error message : "THIS VALUE IS WRITE ONLY"

    On the vbnet FORM, crystal report viewer object was embedded to allow the user to view the report prior to printing it. The crystal Report control, AxCrystalActiveXReportViewer1 was obtained from the ToolBox like all VbNet controls.

    This is the coding

    Code:
    Option Explicit On
    
    Imports System.Data.SqlClient
    Imports System.Data
    Imports System.Drawing
    
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.shared
    Imports CrystalDecisions.Windows.Forms
    
    
    Public Class FrnTextCryReportViewer
    
        Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
    
            Try
                Dim cryfolder As String = "F:\VbNet2008CrystalReport\ CrystalReportOrderDetails.rpt"
                Dim cryRpt As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    
                cryRpt.Load(cryfolder)  
    		
                With  Me.AxCrystalActiveXReportViewer1	
                         .ReportSource = cryRpt  <--- generate error "This value is Write-only "
                          .Refresh()
                End With
    
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    
        End Sub

    Thank you.

    Have a Good Day.

    Cheers,
    Lennie

  2. #2
    New Member
    Join Date
    Mar 2012
    Posts
    5

    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

  3. #3
    New Member
    Join Date
    Mar 2012
    Posts
    5

    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()

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,511

    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
  •  



Click Here to Expand Forum to Full Width