String.Format(...) syntax problem

R

Rich P

I have the following expression that I used in a textbox for Sql Server
Reporting Services 2000. I upgraded to Reporting Services 2005, and
this syntax does not seem to be supported. Does anyone know what the
correct syntax would be?

=String.Format("{0} {1}", new object() {
Parameters!ListNo.Value, Parameters!ListSub.Value}
)

This expressions still works in the Reporting Services 2000 report -
just not in the Reporting Services 2005 report.

Thanks,

Rich
 
P

Patrice

What if you just try
=String.Format("{0}{1}",Parameters!ListNo.Value,Parameters!ListSub.Value) ?

Though passing an array of objects worked, the intent of a paramarray (which
is used AFAIK by String.Format) is to be able to pass an arbitrary number of
arguments. So using explicitely an array of objects is perhaps disallowed
now (as then you could just an object array rather than a paramarray).
 
P

Patrice

If it didn't help please post what you see when using this syntax. If you
have an error never talk about this error without posting the full text of
this error...
 
R

Rich P

string.format("{0}",Parameters!ListNo.Value)

I get a red squiggly line which has some text "Unknown Identifier" for
format - which I did not see in the String. intellisense dropdown. But
I did try the following which did not error out - but sort of defeats
the idea of being able to use ...("{0} {1} - {2}", prm0, prm1, prm2)


=Parameters!ListNo.Value + " " + Parameters!ListSub.Value + " " +
formatDateTime(Parameters!BeginDate.Value,2)

Is there a way to use ...(" {0} {1} ,,,", prm...)

Rich
 
P

Patrice

Ah I gave this a try and got the same result. The trick is that despite the
red line it runs fine. What if you just try to run the report ?

My expression is :
=String.Format("{0} {1}/{2}",Fields!a.Value,Fields!b.Value,Fields!c.Value)

And
=String.Format("{0} {1}/{2}",new
Object(){Fields!a.Value,Fields!b.Value,Fields!c.Value})

also works.

It seems just an issue in the RS expression Window. The red line goes away
if I'm using System.String.Format rather than just String.Format (but now
I've got an error on new when using the second version)...

It seems the expression Windows has its own parser and doesn't know the
compiler will automatically import the System.NameSpace
 
R

Rich P

Hi Patrice,

Yes, your technique worked! It turns out that what was really giving me
a problem was an external assembly I was trying to reference. If I
removed that reference, the report would run with string.format(...).

BTW, do you know where to place a custom dll for Reporting Services 2005
on the development workstation? (and of course the server). I am
trying to test out a simple assembly. I have placed mysimple.dll (which
I tested out on a simple winform app and it worked fine) anywhere in
C:\Program Files\anywhere it reference Reporting Services or Report
Designer. Note: for the old Reporting Services 2000 report - the
VS2003 dll works fine here but not my VS2005 dll

C:\Program Files\Microsoft SQL Server\80\Tools\Report
Designer\mysimple.dll

no joy

also tried the VS2005 dll at these 2 places:

C:\Program Files\Microsoft SQL Server\90\Tools\Reporting
Services\mysimple.dll

also no joy!

C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\mysimple.dll

no joy here either. Any ideas where on the development workstation I
should place this dll? are there any config files I need to deal with
on the developlment workstation (I know I have to deal with
rssvrpolicy.config on the server)

Thanks

Rich
 
R

Rich P

Turns out my issue(s) was/were with back assembly references.
String.Format(...) was OK afterall. Reporting Services 2005 is slightly
different from Reporting Services 2000 in where you deploy assemblies
to. For RS 2005 you deploy a custom assembly to:

C:\Program Files\Microsoft Visual Studio
8\Common7\IDE\PrivateAssemblies\myCustomAssembly.dll

on the development workstation. And on the production server you deploy
a custom assembly to:

C:\Program Files\Microsoft SQL Server\MSSQL.1\Reporting
Services\ReportServer\bin\myCustomAssembly.dll

and on the workstation you modify RSPreviewPolicy.config for permission
(located in the same folder as the assembly - ...\PrivateAssemblies\ --
by adding the following piece of script:

<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="MyExtensionCodeGroup"
Description="Code group for myCustomAssembly">
<IMembershipCondition class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft Visual Studio
8\Common7\IDE\PrivateAssemblies\myCustomAssembly.dll"
/>
</CodeGroup>

add this just under a previous <CodeGroup...></CodeGroup>

And for the server you modify rssrvpolicy.config with the same piece of
script as above - the server rssrvpolicy.config will be located at
...\ReportServer\ just before the \bin\ folder.

Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top