|
-
May 22nd, 2008, 06:56 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Eliminating Parameter Prompt in applcation?
I'm using CR 11 along with VB.Net. I have a report that takes 2 parameters that are passed from my VB App. My problem is that when I call the reporting procedure, I'm prompted by CR to enter my parameter values. Is there anyway I can prevent the prompt and pass the values to the report behind the scenes?
Thanks,
-
May 23rd, 2008, 07:22 AM
#2
Frenzied Member
Re: Eliminating Parameter Prompt in applcation?
can you post the code where you are passing them?
-
May 23rd, 2008, 08:44 AM
#3
Thread Starter
PowerPoster
Re: Eliminating Parameter Prompt in applcation?
Here is the VB.Net procedure that creates, passes, and calls the CR.
Code:
Public Sub PrintGroupActivitySummary()
Try
dErr.clsModule = "modReports"
Dim crDoc As New rptGroupActivitySummary
With crConnectionInfo
.ServerName = "sTEST"
.DatabaseName = "DACK"
.UserID = "CRVBNETSQL"
.Password = "password"
.IntegratedSecurity = True
End With
'Create Crystal Parameter
Dim parameterFields As CrystalDecisions.Shared.ParameterFields
Dim parameterField As CrystalDecisions.Shared.ParameterField
Dim spValue As CrystalDecisions.Shared.ParameterDiscreteValue
Dim spValue1 As CrystalDecisions.Shared.ParameterDiscreteValue
spValue = New CrystalDecisions.Shared.ParameterDiscreteValue
spValue1 = New CrystalDecisions.Shared.ParameterDiscreteValue
parameterFields = New CrystalDecisions.Shared.ParameterFields
parameterField = New CrystalDecisions.Shared.ParameterField
parameterField.ParameterFieldName = "@userID"
spValue.Value = mstrUserID
parameterField.CurrentValues.Add(spValue)
parameterFields.Add(parameterField)
parameterField.ParameterFieldName = "@groupID"
spValue1.Value = mIntGroupID
parameterField.CurrentValues.Add(spValue1)
parameterFields.Add(parameterField)
'crDoc.RecordSelectionFormula = strFormula
frmReports.crViewer.ParameterFieldInfo = parameterFields
frmReports.crViewer.ReportSource = crDoc
frmReports.crViewer.DisplayGroupTree = False
frmReports.ShowDialog()
Catch ex As Exception
dErr.clsProcedure = "PrintGroupActivitySummary()"
dErr.clsMsg = ex.Message
dErr.OnlineErrorHandler(dErr.clsModule, dErr.clsProgram, dErr.clsProcedure, dErr.clsMsg)
End Try
End Sub
-
May 23rd, 2008, 09:02 AM
#4
Frenzied Member
Re: Eliminating Parameter Prompt in applcation?
is it throwing an exception at all?
-
May 23rd, 2008, 09:31 AM
#5
Frenzied Member
Re: Eliminating Parameter Prompt in applcation?
I usually just use:
crReportDocument.SetParameterValue("@paramName", paramValue)
-
May 23rd, 2008, 09:34 AM
#6
Thread Starter
PowerPoster
Re: Eliminating Parameter Prompt in applcation?
Since there is 2 parameters, what would the full syntax be?
-
May 23rd, 2008, 09:45 AM
#7
Thread Starter
PowerPoster
Re: Eliminating Parameter Prompt in applcation?
Besoup,
I actually just created 2 lines of your example and that seemed to work. However, the report is not showing the data like it should be.
-
May 23rd, 2008, 09:46 AM
#8
Frenzied Member
Re: Eliminating Parameter Prompt in applcation?
try this
vb Code:
Public Sub PrintGroupActivitySummary()
Try
dErr.clsModule = "modReports"
Dim crDoc As New rptGroupActivitySummary
With crConnectionInfo
.ServerName = "sTEST"
.DatabaseName = "DACK"
.UserID = "CRVBNETSQL"
.Password = "password"
.IntegratedSecurity = True
End With
crDoc.SetParameterValue("@userID", mstrUserID)
crDoc.SetParameterValue("@groupID", mIntGroupID)
frmReports.crViewer.ReportSource = crDoc
frmReports.crViewer.DisplayGroupTree = False
frmReports.ShowDialog()
Catch ex As Exception
dErr.clsProcedure = "PrintGroupActivitySummary()"
dErr.clsMsg = ex.Message
dErr.OnlineErrorHandler(dErr.clsModule, dErr.clsProgram, dErr.clsProcedure, dErr.clsMsg)
End Try
End Sub
-
May 23rd, 2008, 09:49 AM
#9
Frenzied Member
Re: Eliminating Parameter Prompt in applcation?
 Originally Posted by blakemckenna
However, the report is not showing the data like it should be.
what do you mean?
-
May 23rd, 2008, 10:05 AM
#10
Thread Starter
PowerPoster
Re: Eliminating Parameter Prompt in applcation?
My report should be showing at the least...Literals and its not. Here is what 1 of 3 formulas look like that reference the Stored Procedures.
Code:
Formula 1
Dim cnt1 as Number
If {prcSelectGASR_NewIR;1.NewIR} > 0 Then
cnt1 = {prcSelectGASR_NewIR;1.NewIR}
formula = "New Incident Requests for " & {prcSelectGASR_NewIR;1.groupName} & ": " & Replace (ToText (cnt1), ".00" ,"")
Else
cnt1 = 0
formula = "New Incident Requests for " & {prcSelectGASR_NewIR;1.groupName} & ": " & Replace (ToText (cnt1), ".00" ,"")
End If
prcSelectGASR_NewIR is a Stored Procedure. Below is the Select statement for this SP.
Code:
USE [DACK]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[prcSelectGASR_NewIR]
(
@userID varchar(25),
@groupID int
)
AS
BEGIN
DECLARE @userIDStart varchar(25)
DECLARE @userIDEnd varchar(25)
DECLARE @groupIDStart int
DECLARE @groupIDEnd int
-- Check and initial for any nulls
IF @userID = null
SET @userID = ''
IF @groupID = null
SET @groupID = 0
-- set userID selection range
IF @userID > ''
BEGIN
SET @userIDStart = @userID
SET @userIDEnd = @userID
END
ELSE
BEGIN
SET @userIDStart = ''
SET @userIDEnd = 'ZZZZZZZZZZZZZZZZZZZZZZZZZ'
END
-- set userID selection range
IF @groupID > ''
BEGIN
SET @groupIDStart = @groupID
SET @groupIDEnd = @groupID
END
ELSE
BEGIN
SET @groupIDStart = 0
SET @groupIDEnd = 99999999
END
SELECT B.groupName,
Count(C.statusID) as 'NewIR'
FROM tblGroupMembers B,
tblRequest C
WHERE (B.roleID = 1) AND
(B.empID Between @userIDStart And @userIDEnd) AND
(B.groupID Between @groupIDStart And @groupIDEnd) AND
(C.statusID = 13) AND
(C.requestDate >= GetDate() - 1) AND
(B.groupID = C.groupID)
GROUP BY B.groupName
END
Last edited by blakemckenna; May 23rd, 2008 at 10:09 AM.
Blake
-
May 23rd, 2008, 10:27 PM
#11
Re: Eliminating Parameter Prompt in applcation?
I use this for VB6
References:
Crystal Reports Viewer Control
Crystal Reports ActiveX Designer Run Time Library
Code:
' Typical Variable Declarations
dim crApp as New CRAXDRT.Application
dim crRept as New 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.ReportSource = crRept
crViewer1.viewReport
-
May 24th, 2008, 07:17 PM
#12
Thread Starter
PowerPoster
Re: Eliminating Parameter Prompt in applcation?
I figured it out....
Thanks for the help guys..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|