473,385 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Crytal Reports...Export Error with parms

Hey all,

I am trying to try get a crytal report running properly. A "Hello World"
report that does not add criteria to the record selection formula of the
report (either in the development tool, or in the code) works fine.

However, when I try to add any parameter through the record selection
formula and/or the report parameters method, the report crashes.

I have tried each of the methods:

1. Use the Record Selection Formula property:

crReportDocument.DataDefinition.RecordSelectionFor mula = "{qryTest.ID} =
54"

2. Use the Crystal Parameters collection(s)

crParameterFieldDefinitions =
crReportDocument.DataDefinition.ParameterFields

crParameterFieldDefinition = crParameterFieldDefinitions.Item("[@TestID]")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterDiscreteValue = New
CrystalDecisions.Shared.ParameterDiscreteValue()

crParameterDiscreteValue.Value = 54
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues)
Both of the methods above work fine on my development machine but the
testing server gives these errors.

I also set the record selection formula in the report to automatically set
the TestID parameter = 54 and then tested that report on the testing server
and everything worked.

So the issue seems to be with populating the crystal report's parameters at
runtime. The error that comes back with a logon failure at the .Export
line.

I have tried two methods to logon to the reports:
####################
Basic:
With tliTableLogonInfo.ConnectionInfo
.ServerName = m_strDSNName
.DatabaseName = m_strDatabase
.UserID = m_strUserId
.Password = m_strPassword
End With

'setup each connection in the report
For Each tTable In crReportDocument.Database.Tables
tTable.ApplyLogOnInfo(tliTableLogonInfo)
Next tTable
####################
and Complex (loops through sub-reports):
Dim mySection As Section
Dim mySections As Sections
Dim myReportObject As ReportObject
Dim myReportObjects As ReportObjects
Dim mySubReportObject As SubreportObject
Dim mySubRepDoc As New ReportDocument()

'Declare all of the sections of the main report
mySections = crReportDocument.ReportDefinition.Sections

'Loop through the sections in the main report to find the subreport objects
'then set the logon information to the subreport
Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo

For Each mySection In mySections
myReportObjects = mySection.ReportObjects

For Each myReportObject In myReportObjects
If myReportObject.Kind = ReportObjectKind.SubreportObject Then
'Subreport Found - convert the report object to a sub report type
mySubReportObject = CType(myReportObject, SubreportObject)
'Set the specific instance of this subreport
mySubRepDoc = mySubReportObject.OpenSubreport
(mySubReportObject.SubreportName)

'Set the login information for the current subreport(found)
For Each crTable In mySubRepDoc.Database.Tables
myLogin = crTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = m_strDSNName
myLogin.ConnectionInfo.DatabaseName = m_strDatabase
myLogin.ConnectionInfo.UserID = m_strUserId
myLogin.ConnectionInfo.Password = m_strPassword
crTable.ApplyLogOnInfo(myLogin)
Next
End If
Next
Next
####################
Does anyone know of other methods to filter a report at runtime? Or is
there a Crystal DLL that I need to move from my dev machine to the server
to allow for the record selection properties to be set at runtime?

OR ANY OTHER INFO WOULD BE GREAT!!!

Thanks,

TJ
Nov 18 '05 #1
1 1654
This is working code... In the report design, the parameter name is @pBDate
and is a DateTime type. In the Select Expert, I use.... is equal to and
the value is {?@pBDate} which takes the passed parameter to the cr query
renderer.

If you encounter login problems, let me know - I have some gotcha's that
remedy that.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

'public class....
'inherits....

'Web Form Designer....

Dim cdoc As ReportDocument

Private Sub Page_Load...

'load cr object...
cdoc = New CrystalReport1

'...or you can also do this...
'crDoc.Load("C:\reports\CrystalReport1.rpt")

Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo

crConnectionInfo = New ConnectionInfo
With crConnectionInfo
.ServerName = "sqlServer"
.DatabaseName = "sqlDatabase"
.UserID = "sqlLogin"
.Password = "password"
End With

crDatabase = cdoc.Database
crTables = crDatabase.Tables

For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next

Dim crPFDs As ParameterFieldDefinitions
Dim crPFD As ParameterFieldDefinition

Dim crParameterValues As New ParameterValues
Dim crPBdate As New ParameterDiscreteValue

crPFDs = cdoc.DataDefinition.ParameterFields
crPBdate.Value = "11/28/03"
crPFD = crPFDs.Item("@pBDate")
crParameterValues = crPFD.CurrentValues
crParameterValues.Add(crPBdate)
crPFD.ApplyCurrentValues(crParameterValues)

Me.CrystalReportViewer1.ReportSource = cdoc

End Sub

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz

"Tim Jones" <ti**********@yahoo.ca> wrote in message
news:Xn*********************************@24.70.95. 211...
Hey all,

I am trying to try get a crytal report running properly. A "Hello World"
report that does not add criteria to the record selection formula of the
report (either in the development tool, or in the code) works fine.

However, when I try to add any parameter through the record selection
formula and/or the report parameters method, the report crashes.

I have tried each of the methods:

1. Use the Record Selection Formula property:

crReportDocument.DataDefinition.RecordSelectionFor mula = "{qryTest.ID} =
54"

2. Use the Crystal Parameters collection(s)

crParameterFieldDefinitions =
crReportDocument.DataDefinition.ParameterFields

crParameterFieldDefinition = crParameterFieldDefinitions.Item("[@TestID]")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterDiscreteValue = New
CrystalDecisions.Shared.ParameterDiscreteValue()

crParameterDiscreteValue.Value = 54
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues)
Both of the methods above work fine on my development machine but the
testing server gives these errors.

I also set the record selection formula in the report to automatically set
the TestID parameter = 54 and then tested that report on the testing server and everything worked.

So the issue seems to be with populating the crystal report's parameters at runtime. The error that comes back with a logon failure at the .Export
line.

I have tried two methods to logon to the reports:
####################
Basic:
With tliTableLogonInfo.ConnectionInfo
.ServerName = m_strDSNName
.DatabaseName = m_strDatabase
.UserID = m_strUserId
.Password = m_strPassword
End With

'setup each connection in the report
For Each tTable In crReportDocument.Database.Tables
tTable.ApplyLogOnInfo(tliTableLogonInfo)
Next tTable
####################
and Complex (loops through sub-reports):
Dim mySection As Section
Dim mySections As Sections
Dim myReportObject As ReportObject
Dim myReportObjects As ReportObjects
Dim mySubReportObject As SubreportObject
Dim mySubRepDoc As New ReportDocument()

'Declare all of the sections of the main report
mySections = crReportDocument.ReportDefinition.Sections

'Loop through the sections in the main report to find the subreport objects 'then set the logon information to the subreport
Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo

For Each mySection In mySections
myReportObjects = mySection.ReportObjects

For Each myReportObject In myReportObjects
If myReportObject.Kind = ReportObjectKind.SubreportObject Then
'Subreport Found - convert the report object to a sub report type
mySubReportObject = CType(myReportObject, SubreportObject)
'Set the specific instance of this subreport
mySubRepDoc = mySubReportObject.OpenSubreport
(mySubReportObject.SubreportName)

'Set the login information for the current subreport(found)
For Each crTable In mySubRepDoc.Database.Tables
myLogin = crTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = m_strDSNName
myLogin.ConnectionInfo.DatabaseName = m_strDatabase myLogin.ConnectionInfo.UserID = m_strUserId
myLogin.ConnectionInfo.Password = m_strPassword
crTable.ApplyLogOnInfo(myLogin)
Next
End If
Next
Next
####################
Does anyone know of other methods to filter a report at runtime? Or is
there a Crystal DLL that I need to move from my dev machine to the server
to allow for the record selection properties to be set at runtime?

OR ANY OTHER INFO WOULD BE GREAT!!!

Thanks,

TJ

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
8
by: An Ony | last post by:
Hello, I'm trying to write a program (dll) to use with mIRC. mIRC wants me to use these kind of functions: int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show,...
3
by: Russ | last post by:
I have a page that uses crystal reports to generate reports from a SQl server database. As of a week ago everything was working fine, but now I am all of the sudden getting errors. To the best of...
2
by: GFro | last post by:
I am getting the following error since we upgraded from .NET Framework 1.0 to 1.1. The reports all ran fine yesterday. I get this error in all apps with reports. The apps run fine but the...
1
by: Hardy Wang | last post by:
Hi all, I have a piece of code in my C# console application to export from crystal report files to PDF. For some reports files, I get errors below. I have Crystal Reports 8.5 with service pack...
3
by: Peter | last post by:
VS 2005 Pro. I am getting the following error when I try to export a report to PDF or any other format using Crystal Reports 11 library. Does anyone knows how to fix this problem, the same code...
2
by: =?Utf-8?B?Um9iZXJ0?= | last post by:
About the time we installed Windows Server 2003 SP2 on our Web servers, our exports to Excel stopped working from Crystal Reports .NET within all our ASP.NET applications. However, the exports to...
3
by: manjitsarma | last post by:
I am getting following Exception in opening crystal report in an ASP.NET application. WebReport Control error:System Exception:Load Report failed. Once crytal reports are opened one by...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.