locked
CR10 set datasource before parameters RRS feed

  • Question

  • User-1967577788 posted

    Hi All,

    I am aware that there are a few threads on here regarding the way you have to pass your report parameters after setting the datasource.
    (It seems that whenever you bind the datasource on a report, all parameters are cleared. In previous versions of CR this wasnt a problem.)

    I have a large web application with >500 crystal reports invoked from many different pages and methods.

    Does anyone know of a way to prevent CR from flushing parameters when setting the datasource? Maybe a web.config setting?
    This will mean that I dont need to change every page in my application to solve this problem.

    Many Thanks,

    Dan

    Monday, August 20, 2012 5:22 AM

All replies

  • User-578610739 posted

    Hi DotNetWeasel,

    First of all I said, that there is no need of flushing by crytal report , if your current datasource and dynamically binding data source is same.

    CR is flush parameter, if you change anything in database which you used in report.

    For

    Does anyone know of a way to prevent CR from flushing parameters when setting the datasource? Maybe a web.config setting?

    see link.

    http://forums.asp.net/t/1835827.aspx/1?Web+config+settings

    Wednesday, August 22, 2012 5:30 AM
  • User-1967577788 posted

    Hi, To try and explain this better I've included the below example of how a typical report is generated by code. The sample uses content disposition to return the report as a PDF to the browser. If I set the parameter value 'ReportTitle' before I call 'reportSource.SetDataSource(dt)', the report returns missing parameter values error. If I set the parameter after I call 'reportSource.SetDataSource(dt)' then everything works fine.

    It is this problem that I am trying to get around. I want to be able to set parameters and datasource in any order as per older version of crystal reports. 

     

            Dim strPath As String        
    Dim strFileName As String
    Dim strFullPath As String Dim objpv As New ParameterValues Dim objpdv As New ParameterDiscreteValue Dim mobjcrExportOptions As ExportOptions
    Dim reportSource As New QAMS.ReleaseNotesReport Dim strReportTitle As String Try reportSource.SetDataSource(dt) strPath = "C:\temp\" strFileName = String.Format("Release Notes {0}.pdf", r.releaseVersion) strReportTitle = String.Format("{0} - Version {1} Release Notes", currentApplication.appName, r.releaseVersion) If System.IO.Directory.Exists(strPath) = False Then System.IO.Directory.CreateDirectory(strPath) End If strFullPath = strPath & strFileName Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions crDiskFileDestinationOptions.DiskFileName = strFullPath mobjcrExportOptions = reportSource.ExportOptions With mobjcrExportOptions .DestinationOptions = crDiskFileDestinationOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat End With reportSource.SetParameterValue("ReportTitle", strReportTitle) reportSource.Export() reportSource.Dispose() HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & strFileName) HttpContext.Current.Response.WriteFile(strFullPath) HttpContext.Current.Response.End() Catch ex As Exception Diagnostics.Debug.WriteLine(ex.Message) End Try

    Thursday, August 23, 2012 10:04 AM
  • User-578610739 posted

    Hi DotNetWeasel,

    Right now I don't have crystal report as well as .net.

    You see in below link and compare where you are wrong.

    http://www.codeproject.com/Articles/9263/How-to-pass-discrete-parameters-to-Crystal-Reports

    http://p2p.wrox.com/book-professional-crystal-reports-vs-net/17318-how-pass-parameter-crystal-report-using-c.html

    http://65.39.148.51/Articles/18332/Crystal-Report-Basics-and-Integration-with-DataSet

    Friday, August 24, 2012 1:37 AM
  • User-578610739 posted

    Hi

    also this link. you can dowenload the source code also.

    http://65.39.148.51/Articles/22135/How-to-Pass-Parameters-to-Crystal-Reports-at-Runti

    Friday, August 24, 2012 1:38 AM
  • User-1967577788 posted

    I think you may have misread the post. The report is working so this isnt about where I have gone wrong.

    My question is can I prevent the new requirement in Crystal Reports 10 to set the parameters after the datasource.

    Friday, August 31, 2012 9:14 AM