Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameters are not being passed to crystal reports

Status
Not open for further replies.

prettyangel

Programmer
Sep 2, 2005
38
NG
refer to faq222-2067 posted on the 20th of June 02.

I still maintain that I need to know how to pass the value of a parameter to crystal reports.

I have a stored procedure in sql server 7.0 and created a parameter collection to create the required parameter in Visual Basic 6.0 environment, but if I may ask does the code below store my output?

if yes, how do I now pass prmOutput to crystal reports?
what code snippet will do the job please?

Set prmOutput = .CreateParameter("@cname", adVarWChar, adParamOutput, 255)
 
The answer to your question is no, not exactly. Let me go over some of the code in the FAQ:
Code:
1    Set prmInput = .CreateParameter("@cid", adInteger, adParamInput, , InCID)
2    Set prmOutput = .CreateParameter("@cname", adVarWChar, adParamOutput, 255)
3    .Parameters.Append prmInput
4    .Parameters.Append prmOutput
5    .Execute
6    GetCompanyName = .Parameters(1).Value 'Zero-based array
I numbered the lines for convenient reference.
1 and 2: create parameters. This in and of itself does not store output. You also have to append to the parameters collection and run the related stored procedure.
3 and 4: add the parameters to the command object's parameters collection. This collection needs to match whatever set of parameters a stored procedure expects.
5: run the stored proc. The stored proc uses (well, at least defines, one would assume it also uses) any input parameters and populates any output parameters in the command's parameters collection. In the above, the output parameter is the second member of the collection, since it was added second. (The output parameter was created on line 2 and added on line 4; the other parameter is an input parameter.)
6: return the value of the output parameter as the function's (which you can see in the original FAQ) return value.

So, you need to take the value in your output parameter (element 1 in the example, the first element is element 0), and pass it to your crystal reports program.

It's not clear to me from your post whether you need help getting the output parameter's value, or plugging that value into crystal reports when you have it, or both. Post back if I haven't answered your question.

HTH

Bob
 
Thanks BobRhodes for your response.

I don't want to use a function to get my output.

I want to input my line of codes directly behind the click event of a command button.

secondly, I need help getting the output parameters value as well as plugging that value into crystal reports 7.0
using visual basic code.

Once again thanks for your help.
 
If you want to input your lines of code directly into the click event of a command button, you just put them there instead! Line 6 is how you get the value. The function is simply an example of how to use that value.

As for how to plug the value into Crystal Reports, I don't know off the top of my head. If I were going to do it, I would start by googling to "VB6 Crystal Reports" and reading up on the substantial material you will find. Look for an object in the Crystal Reports object library with a property that can be set to the return value of your output parameter.

Code:
Private Sub Command1_Click()
With myCommand
    Set prmInput = .CreateParameter("@cid", adInteger, adParamInput, , InCID)
    Set prmOutput = .CreateParameter("@cname", adVarWChar, adParamOutput, 255)
    .Parameters.Append prmInput
    .Parameters.Append prmOutput
    .Execute
    [COLOR=red]myCrystalReportsObj.SomeInputValue = .Parameters(1).Value [/color]'Zero-based array
End With
End Sub
Perhaps you'll take a stab at this, and if you run into dificulties post back with more specific questions.

HTH

Bob
 
Thanks BobRodes and MzKitty for your responses.

Do give me time to get back to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top