Groups | Blog | Home
all groups > sql server reporting services > july 2007 >

sql server reporting services : Pasing parameter-value to method in .dll



Peter
7/19/2007 4:07:58 AM
Hello,

I have a class in a .dll wich I instantiate in reporting services on
the References tab. The instance is called "Myinstance". I also have a
parameter called "parm1".

[quoted text, click to view]

Protected Overrides Sub OnInit()
MyInstance.company(Parameters!parm1.value)
End Sub

The method company is declared "public void company(string _company)".

My problem is, that I get the error:

"... The definition of the report "/MyReport" is invalid. There is an
error on line 1 of custom code: [BC30469] Reference to a non-shared
member requires an object reference."

If, in custom code, I hard-code the parameter to the method company
instead of trying to get it from a parameter, it works, so it look as
if I try to access the parameter-value before the parameter is
available or I'm accessing the parameter in a wrong way.

I need to pass the value of the parameter "parm1" to a method
"company(string _company)" before the report is build, as fields in
the report will call other functions in the .dll and what they return
depends on the value of "parm1" passed to the method "company".

So, any suggestion? What am I doing wrong?

Thanks in advance
/Peter
Michael C
7/19/2007 9:14:02 AM

Hey Peter.

Add a variable to your assembly call such as:

Protected Overrides Sub OnInit(parm1 as string)
MyInstance.company(Parameters!parm1.value)
End Sub

Then call you custom code like:

=code.oninit(parameters!parm1.value)

Michael

[quoted text, click to view]
Michael C
7/19/2007 9:20:06 AM
Oops one small change


[quoted text, click to view]

Protected Overrides Sub OnInit(parm1 as string)
MyInstance.company(parm1)
End Sub

Michael


[quoted text, click to view]
Peter
7/19/2007 11:48:25 PM
On 19 Jul., 18:20, Michael C <Micha...@discussions.microsoft.com>
[quoted text, click to view]

Hello Michael,

Thanks for your reply.

There are two issues:

1) I forgot to mention, that pam1 gets its values from a query, so I
cannot call my custom code as "=code.oninit(parameters!parm1.value)"

2) When I tried the custom code in your message, I got this error:
"... There is an error on line 0 of custom code: [BC30284] sub
'OnInit' cannot be declared 'Overrides' because it does not override a
sub in a base class."

What should I do from here ?

Thanks
/Peter
Michael C
7/20/2007 9:56:02 AM

hey Peter,
Well ...
1) The "Parmameter!Parm1.Value" could be "Fields!MyField.value", or if it is
not generated from the dataset that drives the report (i.e. a secondary
query) then you can use First(Fields!MyField.Value,"MyParmQuery")

2) I haven't worked with Overrides, are you required to have 'Protected
Overrides' in the call, or can you simply state Protected Sub
OnInit(strParm1) or even Public Sub OnInit?

Michael


[quoted text, click to view]
Peter
7/23/2007 12:02:55 AM
On 20 Jul., 18:56, Michael C <Micha...@discussions.microsoft.com>
[quoted text, click to view]

Thanks again Michael,

I have to declared it 'Protected' otherwise it will complain that I
use a different access level.

If I declared it Protected Overrides Sub OnInit(DataArea As String),
that is, with one parameter, I get the error:
sub 'OnInit' cannot be declared 'Overrides' because it does not
override a sub in a base class.

If I declare it without any parameters as Protected Overrides Sub
OnInit(), I get the error
Reference to a non-shared member requires an object reference

If I declare it without 'Overrides' (with and without a parameter) I
get the error
Reference to a non-shared member requires an object reference

So I'm stuck again. I need to use a function that is executed before
the report is generated. I need it to call a method i my .dll with an
argument which is based on a selection from a parameter which in turn
is based on a dataset.

What should I try from here?

Thanks
/Peter
AddThis Social Bookmark Button