Databases Reference
In-Depth Information
In the declaration section of the form class module, you declare an object variable for the Web service
proxy class. The code to implement this in VB is as follows:
Private rs As New localhost_RS.ReportingService
The code in C# is as follows:
private localhost_RS.ReportingService rs = new localhost_RS.ReportingService();
The Get Subscription button uses two object variables to hold the report path name and/or owner name
supplied by the user. You use object type variables so you can pass the value Nothing (VB) or null (C#)
in case no values are provided.
After attaching the current user's security credentials to the Web service proxy object, you use the
ListSubscriptions method to iterate through each subscription object and write associated properties
to list and view subitems. The ListView control will show each of these values in separate columns if
displayed in Detail mode. The last step is to enable the New Subscription button. This button will be
used in the next example. The code to implement this in VB and C# follows:
VB
Private Sub btnGetSubscriptions_Click( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnGetSubscriptions.Click
Dim subscr As localhost_RS.Subscription
Dim strReport As String = IIf(Me.cboReport.Text <> “”, Me.cboReport.Text, _
Nothing)
Dim strOwner As String = IIf(Me.cboOwner.Text <> “”, Me.cboOwner.Text, Nothing)
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
'-- Loop through subscriptions collection, add to listview
For Each subscr In rs.ListSubscriptions(strReport, strOwner)
Dim ListItem As New ListViewItem
With ListItem
.Text = subscr.Description
.SubItems.Add(subscr.Owner)
.SubItems.Add(subscr.EventType)
.SubItems.Add(subscr.LastExecuted)
.SubItems.Add(subscr.Status)
End With
Me.lstvwSubscriptions.Items.Add(ListItem)
Next
'-- Enable new subscription button
Me.btnNewSubscription.Enabled = True
End Sub
C#
private void btnGetSubscriptions_Click(object sender, System.EventArgs e)
{
string strReport = null;
string strOwner = null;
if(this.cboReport.Text!= “”)
{
Search WWH ::




Custom Search