1
+ Public Function GetParameterandValues( ByVal ServerName As String , ByVal ReportServerDBName As String , ByVal ReportName As String , ByVal ReportParameters As Parameters) As String
2
+
3
+ Try
4
+
5
+ Dim ConnStr As String
6
+ Dim SQL As String
7
+
8
+ Dim Param As Parameter
9
+ Dim ParameterOutput As String
10
+ Dim ParameterName As String
11
+ Dim ParameterValue As String
12
+ Dim ParameterLabel As String
13
+
14
+ Dim SQLConn As System.Data.SqlClient.SqlConnection
15
+ Dim SQLCmd As System.Data.SqlClient.SqlCommand
16
+ Dim SQLRdr As System.Data.SqlClient.SqlDataReader
17
+
18
+ ParameterOutput = ""
19
+ ParameterName = ""
20
+ ParameterValue = ""
21
+ ParameterLabel = ""
22
+
23
+ ConnStr = "Data Source=" + ServerName + ";Initial Catalog=" + ReportServerDBName + ";Integrated Security=SSPI;"
24
+
25
+ SQLConn = New System.Data.SqlClient.SqlConnection()
26
+ SQLCmd = New System.Data.SqlClient.SqlCommand()
27
+
28
+ SQLConn.ConnectionString = ConnStr
29
+ SQLConn.Open()
30
+
31
+ SQL = "SELECT Name = Paravalue.value('Name[1]', 'VARCHAR(250)') FROM (SELECT C.Name,CONVERT(XML,C.Parameter) AS ParameterXML FROM ReportServer.dbo.Catalog C WHERE C.Content is not null AND C.Type = 2 AND C.Name = '" + ReportName + "') a CROSS APPLY ParameterXML.nodes('//Parameters/Parameter') p ( Paravalue )"
32
+ SQLCmd.Connection = SQLConn
33
+ SQLCmd.CommandType = System.Data.CommandType.Text
34
+ SQLCmd.CommandText = SQL
35
+
36
+ SQLRdr = SQLCmd.ExecuteReader()
37
+
38
+ While SQLRdr.Read()
39
+
40
+ ParameterName = SQLRdr( "Name" )
41
+ Param = ReportParameters(ParameterName)
42
+
43
+ ParameterOutput = ParameterOutput + System.Environment.NewLine + ParameterName + Space( 30 - Len(ParameterName)) + ": "
44
+
45
+
46
+ If Param.IsMultivalue = False Then
47
+ ParameterValue = Param.Value
48
+ ParameterLabel = Param.Label
49
+ If ParameterLabel Is Nothing Then
50
+ ParameterOutput = ParameterOutput + ParameterValue
51
+ Else
52
+ ParameterOutput = ParameterOutput + ParameterLabel
53
+ End If
54
+ Else
55
+ For Mloop As Integer = 0 To Param.Count - 1
56
+ ParameterOutput = ParameterOutput + Param.Label(Mloop).ToString() + "-" + Param.Value(Mloop).ToString()
57
+ If Not (Mloop = Param.Count - 1 ) Then
58
+ ParameterOutput = ParameterOutput + ","
59
+ End If
60
+ Next
61
+ End If
62
+
63
+ End While
64
+
65
+ Return (ParameterOutput)
66
+ Catch ex As Exception
67
+ Return (ex.Message)
68
+ End Try
69
+
70
+ End Function
0 commit comments