Sunday, February 19, 2012

global code

Is there a place where I can put custom code so that all reports in a
solution can access the same code?
I now copy the code into every new report I createYou can have assemblies that are shared between reports. Search books on
line for custom code and it will tell you all about it.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Servé La" <blabla@.bestaatniet.nl> wrote in message
news:uTpyCPrCFHA.3924@.TK2MSFTNGP15.phx.gbl...
> Is there a place where I can put custom code so that all reports in a
> solution can access the same code?
> I now copy the code into every new report I create
>|||"Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> schreef in bericht
news:%2393IKdsCFHA.3376@.TK2MSFTNGP12.phx.gbl...
> You can have assemblies that are shared between reports. Search books on
> line for custom code and it will tell you all about it.
Thats not what I meant. The code for calling the assemblies will have to be
duplicated in every report one creates.|||Servé La wrote:
> Thats not what I meant. The code for calling the assemblies will have
> to be duplicated in every report one creates.
I did'nt understand your question. Each report is like a single programm.
If i need an assembly in two programms, i have to write
IMPORTS myassemblyclass
in BOTH programms
frank|||I haven't done this but I think it would work. It looks to me that
report.rdl in this directory:
C:\Program Files\Microsoft SQL Server\80\Tools\Report
Designer\ProjectItems\ReportProject
Is what is used by the report wizard. My guess is if you change this then
all the new reports would have the code. Save a copy of it just in case. Let
me know if that works for you.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Servé La" <blabla@.bestaatniet.nl> wrote in message
news:uS0vSqsCFHA.3324@.TK2MSFTNGP15.phx.gbl...
> "Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> schreef in bericht
> news:%2393IKdsCFHA.3376@.TK2MSFTNGP12.phx.gbl...
> > You can have assemblies that are shared between reports. Search books on
> > line for custom code and it will tell you all about it.
> Thats not what I meant. The code for calling the assemblies will have to
be
> duplicated in every report one creates.
>|||"Frank Matthiesen" <fm@.xax.de> schreef in bericht
news:36hi9eF50g2hqU1@.individual.net...
> Servé La wrote:
> > Thats not what I meant. The code for calling the assemblies will have
> > to be duplicated in every report one creates.
> I did'nt understand your question. Each report is like a single programm.
> If i need an assembly in two programms, i have to write
> IMPORTS myassemblyclass
> in BOTH programms
Suppose you have created a component where you have to set a few properties
and then calculate some value.
You create a function for this like the following:
Function Compute(name as String, x as Integer, y as Integer, z as Integer)
as Integer
Dim obj as new MyComponents.Component(name)
obj.X = x
obj.Y = y
obj.Z = z
Try
Compute = obj.Compute()
Catch e as OopsException
Compute = -1
End Try
End Function
You then want to use this function in a few reports. Right now I see no
other way then to put that code in every report and call it, while I
expected to put that function somewhere globally where all reports could
access it. In reality the code gets a lot more complex very fast.|||Could you not store the function as a 'stored procedure' in the database
then just call the stored procedure as you need it?
Dale
"Servé La" <blabla@.bestaatniet.nl> wrote in message
news:%23whb6AtCFHA.1188@.tk2msftngp13.phx.gbl...
> "Frank Matthiesen" <fm@.xax.de> schreef in bericht
> news:36hi9eF50g2hqU1@.individual.net...
> > Servé La wrote:
> > > Thats not what I meant. The code for calling the assemblies will have
> > > to be duplicated in every report one creates.
> >
> > I did'nt understand your question. Each report is like a single
programm.
> > If i need an assembly in two programms, i have to write
> > IMPORTS myassemblyclass
> > in BOTH programms
> Suppose you have created a component where you have to set a few
properties
> and then calculate some value.
> You create a function for this like the following:
> Function Compute(name as String, x as Integer, y as Integer, z as Integer)
> as Integer
> Dim obj as new MyComponents.Component(name)
> obj.X = x
> obj.Y = y
> obj.Z = z
> Try
> Compute = obj.Compute()
> Catch e as OopsException
> Compute = -1
> End Try
> End Function
> You then want to use this function in a few reports. Right now I see no
> other way then to put that code in every report and call it, while I
> expected to put that function somewhere globally where all reports could
> access it. In reality the code gets a lot more complex very fast.
>|||You are not being consistent here. On the one hand you said you understood
about using custom assemblies. On the other hand you posted this. Your code
can go in a custom assembly once. Then all you have to do is reference that
assembly in your reports. You do not have to have that function defined in
each and every report.
As I suggested before, read up on custom code. You can do custom code two
ways, code behind report and in your own assembly. What you are talking
about here is code behind report.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Servé La" <blabla@.bestaatniet.nl> wrote in message
news:%23whb6AtCFHA.1188@.tk2msftngp13.phx.gbl...
> "Frank Matthiesen" <fm@.xax.de> schreef in bericht
> news:36hi9eF50g2hqU1@.individual.net...
> > Servé La wrote:
> > > Thats not what I meant. The code for calling the assemblies will have
> > > to be duplicated in every report one creates.
> >
> > I did'nt understand your question. Each report is like a single
programm.
> > If i need an assembly in two programms, i have to write
> > IMPORTS myassemblyclass
> > in BOTH programms
> Suppose you have created a component where you have to set a few
properties
> and then calculate some value.
> You create a function for this like the following:
> Function Compute(name as String, x as Integer, y as Integer, z as Integer)
> as Integer
> Dim obj as new MyComponents.Component(name)
> obj.X = x
> obj.Y = y
> obj.Z = z
> Try
> Compute = obj.Compute()
> Catch e as OopsException
> Compute = -1
> End Try
> End Function
> You then want to use this function in a few reports. Right now I see no
> other way then to put that code in every report and call it, while I
> expected to put that function somewhere globally where all reports could
> access it. In reality the code gets a lot more complex very fast.
>|||"Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> schreef in bericht
news:uvhbbYtCFHA.2540@.TK2MSFTNGP09.phx.gbl...
> You are not being consistent here. On the one hand you said you understood
> about using custom assemblies. On the other hand you posted this. Your
code
> can go in a custom assembly once. Then all you have to do is reference
that
> assembly in your reports. You do not have to have that function defined in
> each and every report.
> As I suggested before, read up on custom code. You can do custom code two
> ways, code behind report and in your own assembly. What you are talking
> about here is code behind report.
I guess I meant code behind then. I have some cases where methods need to be
called from code behind in a certain order so it would be nice to have this
functionality in one single function defined somewhere globally.
I take it the answer is "no you cant do this" then :)|||You are still missing the point. You can have code behind and you can have
custom assemblies. You can definitely put your common functions in a custom
assembly that all your reports will use. You can have both code behind and
custom assemblies. The tricky part of custom assemblies is deployment of the
assembly.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Servé La" <blabla@.bestaatniet.nl> wrote in message
news:%233S6lYODFHA.3256@.tk2msftngp13.phx.gbl...
> "Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> schreef in bericht
> news:uvhbbYtCFHA.2540@.TK2MSFTNGP09.phx.gbl...
> > You are not being consistent here. On the one hand you said you
understood
> > about using custom assemblies. On the other hand you posted this. Your
> code
> > can go in a custom assembly once. Then all you have to do is reference
> that
> > assembly in your reports. You do not have to have that function defined
in
> > each and every report.
> >
> > As I suggested before, read up on custom code. You can do custom code
two
> > ways, code behind report and in your own assembly. What you are talking
> > about here is code behind report.
> I guess I meant code behind then. I have some cases where methods need to
be
> called from code behind in a certain order so it would be nice to have
this
> functionality in one single function defined somewhere globally.
> I take it the answer is "no you cant do this" then :)
>|||"BruceLC" <brucelc@.newsgroup.nospam> schreef in bericht
news:OOGvMxRDFHA.1040@.TK2MSFTNGP09.phx.gbl...
> You are still missing the point. You can have code behind and you can have
> custom assemblies. You can definitely put your common functions in a
custom
> assembly that all your reports will use. You can have both code behind and
> custom assemblies. The tricky part of custom assemblies is deployment of
the
> assembly.
I am talking about calling a custom assembly from code behind! It's about
both!!
The methods in the custom assembly need to be called within a certain order
so this has to be done in code behind.|||Try putting your common code in a custom assembly and then placing it into
GAC
--
Alex Mineev
Software Design Engineer. Report expressions; Code Access Security; Xml;
SQE.
This posting is provided "AS IS" with no warranties, and confers no rights
"Servé La" <blabla@.bestaatniet.nl> wrote in message
news:uTpyCPrCFHA.3924@.TK2MSFTNGP15.phx.gbl...
> Is there a place where I can put custom code so that all reports in a
> solution can access the same code?
> I now copy the code into every new report I create
>

No comments:

Post a Comment