Advertisement

10.27.2003 at 01:09PM PST, ID: 20779605
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Crystal Report & Stored Procedure & VB

Tags: crystal, report, stored, procedure
Hello,

I need advice on how to implement Crystal Reports within VB application using SQL Server 2000 as back-end.

I have stored procedure that I intend using with my Crystal Report. What I want to do is to use VB forms to pass parameters to my Report, what is easiest way to do this?

Thank you for all your help!


PS
I'm using VB6 and Crystal 8.5
Start your free trial to view this solution
Question Stats
Zone: Database
Question Asked By: tina69
Solution Provided By: DRRYAN3
Participating Experts: 3
Solution Grade: A
Views: 417
Translate:
Loading Advertisement...
10.27.2003 at 02:54PM PST, ID: 9630382

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.27.2003 at 03:07PM PST, ID: 9630446

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.28.2003 at 03:02PM PST, ID: 9637758

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.28.2003 at 03:42PM PST, ID: 9637952

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.28.2003 at 03:56PM PST, ID: 9638010

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.28.2003 at 09:29PM PST, ID: 9639527

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.29.2003 at 07:39AM PST, ID: 9642677

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.29.2003 at 08:48AM PST, ID: 9643309

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.30.2003 at 04:44PM PST, ID: 9654557

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.04.2003 at 12:19PM PST, ID: 9681672

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.04.2003 at 12:49PM PST, ID: 9681888

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.17.2004 at 12:45PM PDT, ID: 11092211

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.17.2004 at 12:49PM PDT, ID: 11092247

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.30.2005 at 09:23AM PDT, ID: 14993745

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.30.2005 at 10:36AM PDT, ID: 14994416

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.01.2005 at 05:52AM PDT, ID: 14998345

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
10.27.2003 at 02:54PM PST, ID: 9630382

Rank: Guru

Start by going to File-Options, Database and check the box for Stored Procedures.

Your stored procedure should return a single recordset, most easily achieved by having the final statement in the stored procedure be a select statement of some kind.

I've found the best performance using the Crystal Reports "Microsoft SQL Server" data source, available under "More Data Sources" in the data explorer displayed when you create a new report.

Select your stored procedure from the list of stored procedures (if yours is not displayed, you have a permissions issue on the SQL server).

As far as VB goes, the only change you'll need to make is how your parameters are named.  If your stored procedure takes a parameter named @PARAM1, then Crystal Reports will name it {?@PARAM1} and that is how you need to reference it when you pass the parameters to CR from VB.

I'll dig up a code example in a minute.
 
10.27.2003 at 03:07PM PST, ID: 9630446

Rank: Guru

You'll need to adapt this to your situation, but this is one way to pass parameters:

Private Sub Command1_Click()
  Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions
  Dim crpParamDef As CRAXDRT.ParameterFieldDefinition
  Dim crpSubreport As CRAXDRT.Report
  Set crpParamDefs = Report.ParameterFields
  For Each crpParamDef In crpParamDefs
    With crpParamDef
    Select Case .ParameterFieldName
      Case "@PARAM1"
        .SetCurrentValue "PARAM1 VALUE"
      Case "@PARAM2"
        .SetCurrentValue "PARAM2 VALUE"
    End Select
    End With
  Next
  Report.EnableParameterPrompting = False
  CRViewer1.ReportSource = Report
  CRViewer1.ViewReport
End Sub  
 
 
10.28.2003 at 03:02PM PST, ID: 9637758
Thank You DRRYAN3 fo quick response,

Question:

For report source
CRViewer1.ReportSource = Report

What is a best way to implement Crystal Reports...
Have Reports on a network and specify network location for reports or
bring reports into VB front-end and have it as part of the application?

I'll have multiple user accessing application and reports

Thanks



 
10.28.2003 at 03:42PM PST, ID: 9637952

Rank: Guru

If you incorporate the reports into the application, then if you need to make minor changes to report layouts, you'll have to redistribute the entire application.  I prefer to keep the .RPT files seperate and in a shared location.  Keeps things a little cleaner in the IDE while developing too.
 
10.28.2003 at 03:56PM PST, ID: 9638010
I'm Sorry, forgot to clarify one more thing

Before running reports user will be prompted to enter begindate and enddate(Format on a back end as date and time).  What exactly will be in
.SetCurrentValue "PARAM1 VALUE"? txtBeginDate and txtEndDate for "PARAM1 VALUE"?

Thank You


 
10.28.2003 at 09:29PM PST, ID: 9639527

Rank: Guru

If you are passing parameters to Crystal Reports use datevalue(txtBeginDate) to pass a date parameter in.  If you were passing them straight into the SQL stored procedure, the text value alone would be fine.

txtBeginDate should be stored in one of the predefined system date formats - I always use mm/dd/yyyy or mm-dd-yyyy.
 
10.29.2003 at 07:39AM PST, ID: 9642677
DRRYAN3,

What are you using for References and Components cause I've tried to use your sample code and it's giving me a "User defined type not defined" on line:
'
Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions
'

Also, can I pass another parameter not from Data entry form but internaly. Basically I will have 3 parameters: 2 parameters(begindate & enddate) will be entered by user, third parameter will
be ID (global variable m_ID will hold that value). How can I pass that ID?  

Can you please also explain a little more what is the difference between when passing parameters to stored procedure and when passing parameters to a report.

For example, I want to display my parameters values on a report what syntax do I need to use?

Thank You



 
10.29.2003 at 08:48AM PST, ID: 9643309

Rank: Guru

Your error message is probably caused by a missing SET on the crParamDefs.  See the example below:

References:

Crystal Reports Viewer Control
Crystal Reports ActiveX Designer Run Time Library

' Typical Variable Declarations
dim crApp as CRAXDRT.Application
dim crRept as CRAXDRT.Report
dim crParamDefs as CRAXDRT.ParameterFieldDefinitions
dim crParamDef as CRAXDRT.ParameterFieldDefiniton
dim crDBTab as CRAXDRT.DatabaseTable

' Open Report File
set crRept = crApp.OpenReport("WHATEVER.RPT")

' Logon to SQL server
crRept.Database.LogonServer "p2ssql.dll", "server name", "database name", "userid", "userpassword"

' Set table locations (because my reports run against multiple servers)
foreach crDBTab in crRep.Database.Tables
  crDBTab.SetLogonInfo "server name", "database name", "userid", "userpassword"
next

' Disable Parameter Prompting for the end user
crRep.EnableParameterPrompting = FALSE

' Gather the list of available parameters from the report
set crParamDefs = crRep.ParameterFields

' Loop through all parameters in the report by name, filling in the appropriate parameter with the right value
foreach crParamDef in crParamDefs
  select case crParamDef.ParameterFieldName
    case "SubTitle"
      crParamDef.SetCurrentValue "My Report Subtitle Goes Here"
    case "@BeginDate"
      crParamDef.SetCurrentValue datevalue(txtBeginDate)
    case "@EndDate"
      crParamDef.SetCurrentValue datevalue(txtEndDate)
    case "@IntegerParam"
      crParamDef.SetCurrentValue val(int(txtIntegerParam))
  end select
next

crViewer1.viewReport

In this example, your stored procedure takes three parameters:  @BeginDate, @EndDate and @IntegerParam.  You need do nothing in Crystal Reports to define these parameters.  The report itself is using an additional parameter, which you must create in Crystal Reports, named SubTitle.  I'll use something like this do put a summary of the parameters used at the top of the report.  Use the field placement tool to drop the parameter field on your report just like any other field.  If you want to further modify the parameters (to display a datetime as text, for example), you'll have to create a formula field which does the conversion and concatenation and then place the formula field on the report.

You can pass any value you want to CR, whether the user typed it or your program generated it in this way.

One of the few times you would want to pass parameters straight to the stored procedure is if you want to create a temporary table to base your report on instead of using a recordset returned by the stored procedure.  Doesn't come up often, but sometimes it's faster.

 
10.30.2003 at 04:44PM PST, ID: 9654557

Rank: Guru

Anything else you need?
Accepted Solution
 
11.04.2003 at 12:19PM PST, ID: 9681672
Thank you DRRYAN3 for all your help, you've been very helpful!

I've been wondering for a while now, it looks like anytime you create CR report that  using Stored Procedure, this report creates a DB connection. So if you have 10 reports that you need to run you'll have 10 connections? Is that true? If it is, is it possible to create one connection(from VB code for example) for all reports?
Also can I use one VB form to pass parameters to all my reports and to use one CRViewer for all reports. Or for each report I wpuld need to use different CRViewer?

Thanks again!


 
11.04.2003 at 12:49PM PST, ID: 9681888

Rank: Guru

You really have no control over the connection use in CR version 8.5.  I haven't really gotten into version 9 yet, but I'll be curious to see if Crystal takes advantage of the connection pooling .Net offers.  I rather doubt it.

As to your second question, you can do pretty much anything you want to do.  For example, I have a single VB app which is really nothing more than a shell containing a menu, a couple of procedures to run and export reports based on parameter entries, etc stored in a database, and an MDI child form containing a viewer.  This allows my users to open as many reports as they have memory for at one time.  Technically, each report is getting a copy of the viewer, but they are created and destroyed on the fly as the user runs reports and closes the preview window.

Glad to help
 
05.17.2004 at 12:45PM PDT, ID: 11092211
I can't use the Keyword "SET" in the folling statement

set crRept = crApp.OpenReport("WHATEVER.RPT")

WHenever I type it VB will autodelete it.
 
05.17.2004 at 12:49PM PDT, ID: 11092247
I can't use the Keyword "SET" in the following statement

set crRept = crApp.OpenReport("WHATEVER.RPT")

WHenever I type it VB will autodelete it.

So I'm getting the same error that tina69 was getting on 10/29/03
 
09.30.2005 at 09:23AM PDT, ID: 14993745
Dear All,
I am using the above method to pass the variables to the report. (.SetCurrentvalue). After running the report I receive nothing except the column headers in the report.
Checked the parameters report on the report object and the currentvalue property shows the value I am passing but the value property is empty, not sure whether that needs to be set as well although in the above code example the value property hasn't been set.
Please help as I am quite behind the time scheduling of the project.
Regards,

D.
 
09.30.2005 at 10:36AM PDT, ID: 14994416

Rank: Guru

This question is TWO YEARS OLD

Open a new question an cough up some points
 
10.01.2005 at 05:52AM PDT, ID: 14998345

DRRYAN3,
Thanks for paying attention to this question.
I opened a new question with the following title "Question Title: Empty screen when running a Crystal Report viewer in Visual basic by passing parameters settings", but i thought could be helpful if i add some notes to the end of this old question as well.

Regards,
D.
 
 
20080236-EE-VQP-29