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 July 20th, 2005, 07:56 AM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crystal Report lossing parameters info

I am having an issue with CR regarding the db connection and its parameter. I have a code below that changes database based on values passed and set parameters for the report, if neccesary. The code works in my local machine, when I run it everything seems to work. When I move it to a different machine the same code does not work. The reports that do not require parameters run however for those requiring parameters failed with the error "Invalid field name". I tried different combination to see if there was something I was stting up incorrectly. I was able to debug this code from the computer having the issue. I check the parameters in the report using rptdocument.DataDefinition.ParameterFields.count and I can see that the ParameterFields collection is reset to 0 right after I execute the line rptDocument.Database.Tables(0).location = tName. That does not happend in my local pc, why it does not retain the information about the parameters after I set to new location?

I am not sure why this behavior, In my local pc this code works fine but moving it to another server the code behaves this way.
Any suggestion will be appreciated (I have been dealing with this for 3 days now)

*** this is the code ***
Public Overloads Sub runReport(ByVal reportName As String, _
           ByVal parameters As ArrayList)

           'connection variables
           Dim crDatabase As Database
           Dim crTables As Tables
           Dim crTable As Table
           Dim crLogOnInfo As New TableLogOnInfo
           Dim crConnInfo As New ConnectionInfo

           Dim p As System.Web.UI.Page = New System.Web.UI.Page
           Dim serverutil As HttpServerUtility = p.Server

           ' this code if for changing connection on the fly. not working as expected
           Try
               rptDocument.Load(serverutil.MapPath(rptPath & reportName))
               With crConnInfo
                   .ServerName = _
                  ConfigurationSettings.AppSettings.Item("RptServerN ame")

                   .DatabaseName = _
                      ConfigurationSettings.AppSettings.Item("RptDatabas eName")
                   .UserID = _
                      ConfigurationSettings.AppSettings.Item("RptUser")
                   .Password = _
                      ConfigurationSettings.AppSettings.Item("RptPass")
               End With
               crLogOnInfo.ConnectionInfo = crConnInfo
               Dim tName As String = rptDocument.Database.Tables(0).Name
               Dim tLocation = crConnInfo.DatabaseName & ".dbo." & tName
               crTable = rptDocument.Database.Tables(0)
               crTable.ApplyLogOnInfo(crLogOnInfo)

               rptDocument.Database.Tables(0).Location = tName 'tLocation


               ' set parameters, if any
               If Not parameters Is Nothing Then
                   'set parameters
                   For Each el As CommonObject In parameters
                       rptDocument.SetParameterValue(el.Id, el.Description)

                   Next

               End If

               Dim s As System.IO.MemoryStream = _
               rptDocument.ExportToStream(ExportFormatType.Portab leDocFormat)

               ' to the browser instead of creating files on disk.
               With HttpContext.Current.Response
                   .ClearContent()
                   .ClearHeaders()
                   .ContentType = "application/pdf"
                   .AddHeader("Content-Disposition", "inline; filename=Report.pdf")
                   .BinaryWrite(s.ToArray)
                   .Flush()
                   .End()

               End With

           Catch ex As Exception
               Throw New AppException(ex.Message)
           End Try

 End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report with Parameters inoonjiffry Crystal Reports 0 September 7th, 2008 06:25 AM
unable to pass parameters to crystal report ukumawat Crystal Reports 1 May 6th, 2006 09:08 AM
Problem passing parameters in Crystal Report. joydip_kanjilal Crystal Reports 0 October 8th, 2004 01:47 AM
Crystal Report dynamic Refresh with new parameters sumansaumya Crystal Reports 0 March 19th, 2004 01:45 AM





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