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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSRS Code "Instance Based" What does it mean.

Status
Not open for further replies.

Peager

Programmer
May 27, 2003
140
US
There is a phrase in the SSRS docs in SQL Server 2008 Books Online, "Using Custom Code References in Expressions (Reporting Services)"

Methods in embedded code must be written in Microsoft Visual Basic and must be instance-based.

What does this mean? (While I AM a programmer, I don't 'talk' vb or any other MS language.)

Many thanks in advance,

Paul
 
An instance-based method refers to a method from an object that has been instantiated from a type (class). Contrast this with a type-based method which is a method that belongs to the type itself and not any particular instance of that type. Type-based methods are defined in Visual Basic via the Shared keyword.

As for the online book saying that methods in embedded code must be instance-based; this doesn't seem to jive with the following embedded code. I can create a text box with each of the following 4 expressions and each one will work just fine, even though I would consider the first 2 to be type-based methods.

=Code.DirectTypeBasedMethod()
=Code.TekTipsClass.TypeBasedMethod()
=Code.IndirectTypeBasedMethod()
=Code.IndirectInstanceBasedMethod()

Code:
Public Shared Function DirectTypeBasedMethod() As String
    Return "Direct type based method return value"
End Function

Public Function IndirectInstanceBasedMethod() As String
    Dim tt As New TekTipsClass
    Return tt.InstanceBasedMethod
End Function

Public Function IndirectTypeBasedMethod() As String
    Return TekTipsClass.TypeBasedMethod
End Function

Public Class TekTipsClass

    Public Shared Function TypeBasedMethod() As String
        Return "TekTipsClass.TypeBasedMethod return value"
    End Function

    Public Function InstanceBasedMethod() As String
        Return "TekTipsClass.InstanceBasedMethod return value"
    End Function

End Class
 
I thought it meant what "instance" you are using. For instance, if you have SQL 2005 instance on your machine as "SQLExpress" and SQL 2008 as "Express2008" you would have to refer to them separately. That's just what I was thinking.
Brett

--------------------------
Web/.net Programmer & DBA
Central PA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top