Groups | Blog | Home
all groups > sql server reporting services > september 2004 >

sql server reporting services : Custom coding


Al Santamaria
9/21/2004 3:25:31 PM
I'm using the Report.References collection to link to some external
Assemblies (developed in C#). Also, I use the Report.Classes collection to
instantiate some classes defined in that assemblies. This works, as I'm
able to show a custom Windows form from the constructors of the instantiated
classes in report initialization time and to get simple values from some
properties. As this approach is extremately useful, I'd like to acquire
maximum flexibility being able to access from these classes to all the
properties of the Report via the corresponding namespaces as follows:

Microsoft.ReportingServices.ReportProcessing
Microsoft.ReportingServices.ReportRendering

As an example, I'd like to access to the Report object, to an existing
Matrix item, etc. I'm trying it this way:

///////////////////////////// C# in the Assembly:
namespace CustomAssembly
{
public class Class1
{
public int
GetRenderedColumnsCount(Microsoft.ReportingServices.ReportRendering.Report
p_Report)
{
return p_Report.Columns;
}

public int
GetMatrixColumnsCount(Microsoft.ReportingServices.ReportRendering.Matrix
p_Matrix)
{
return p_Matrix.Columns;
}
}
}

/////////////////////////////// Report:
First, I reference the Assemblies:
<CodeModules>
<CodeModule>CustomAssembly, Version=1.0.1719.22270, Culture=neutral,
PublicKeyToken=null</CodeModule>
</CodeModules>

Second, I instantiate the Classes:
<Classes>
<Class>
<ClassName>CustomAssembly.Class1</ClassName>
<InstanceName>class1</InstanceName>
</Class>
</Classes>

Last, I tried to use the following expressions in a TextBox.Value but none
of them work:
=Code.class1.GetRenderedColumnsCount(Report)
=Code.class1.GetRenderedColumnsCount(Code.Report)
=Code.class1.GetMatrixColumnsCount(matrix1)
=Code.class1.GetMatrixColumnsCount(Report.matrix1)
=Code.class1.GetMatrixColumnsCount(Report!matrix1)
=Code.class1.GetMatrixColumnsCount(Report("matrix1"))

I'm sure the construction works because I'm showing a MessageBox in the
constructor and other properties are returning the proper value to the
report.

Can anyone, please, tell me what am I doing wrong?

TinaWina
10/28/2004 11:48:01 PM
Hi.
I had this problem and was able to solve it by following these instructions.

Copy your custom assembly from your build location to the report server bin
folder or the Report Designer folder. The default location of the bin folder
for the report server is C:\Program Files\Microsoft SQL
Server\MSSQL\Reporting Services\ReportServer\bin. The default location of the
Report Designer is C:\Program Files\Microsoft SQL Server\80\Tools\Report
Designer.

It should then work
Christina


[quoted text, click to view]
AddThis Social Bookmark Button