how can i pass a null string (and not an empty one)

rated by 0 users
This post has 1 Reply | 1 Follower

Top 500 Contributor
Posts 5
geert deprez Posted: 06-30-2009 5:07 PM

i need to render some reports from ssrs

everything looks quite easy using the web service

there is only one BIG problem

 

I need to pass a null string (null in c#, nothing in vb.net) to the method LoadReport as HistoryID

nothing else works, alternative is a valid datetime string but then ssrs looks for the snapshot report with that date and time

today i have tried whatever, but $null is passing an empty string what is not valid, any other thing does not seem to work neither

code:

$rs = New-WebServiceProxy -uri

http://localhost/reportserver_geman/reportexecution2005.asmx?WSDL

-UseDefaultCredential        #v2 cmdlet

$rs.LoadReport("/HMCReports/PostCodesEnPlaatsen", $null)

 

Generates the error:

Exception calling "LoadReport" with "2" argument(s): "System.Web.Services.Protocols.SoapException: The parameter value provided for 'snapshotID' does not match the parameter type. ---> Microsoft.ReportingServices.Diagnostics.Utilities.ParameterTypeMismatchException: The parameter value provided for 'snapshotID' does not match the parameter type. ---> System.FormatException: String was not recognized as a valid DateTime.

at Microsoft.ReportingServices.WebServer.ReportExecution2005Impl.LoadReport(String Report, String HistoryID, ExecutionInfo2& executionInfo)

at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report, String HistoryID, ExecutionInfo& executionInfo)"

 

In C#:, this works:

                string historyID = null;

                execInfo = rs.LoadReport(reportPath, historyID);

 

and this generates the same error:

                string historyID = "";

                execInfo = rs.LoadReport(reportPath, historyID);

 

Top 500 Contributor
Posts 3

The problem is this, essentially:

PS C:\Users\david> ([string]$null).gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

I can't think of a way around it in PowerShell. Maybe you should file a bug.

Page 1 of 1 (2 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.