Which code segment should you use?

You are creating an administrative Web Part for a Microsoft Windows SharePoint Services application.

You write the following code segment.

Dim mySPFarm As SPFarm = SPWebService.ContentService.Farm
Dim mySPServerCollection As SPServerCollection = mySPFarm.Servers
Dim contentDatabases As ArrayList = New ArrayList ()

You need to add the names of the content databases for non-administrative sites that are available within the server farm to the ArrayList object.

Which code segment should you use?

You are creating an administrative Web Part for a Microsoft Windows SharePoint Services application.

You write the following code segment.

Dim mySPFarm As SPFarm = SPWebService.ContentService.Farm
Dim mySPServerCollection As SPServerCollection = mySPFarm.Servers
Dim contentDatabases As ArrayList = New ArrayList ()

You need to add the names of the content databases for non-administrative sites that are available within the server farm to the ArrayList object.

Which code segment should you use?

A.
Dim webAppCollection As SPWebApplicationCollection = _
SPWebService.ContentService.WebApplications
If Not (webAppCollection Is Nothing) Then
For Each webApp As SPWebApplication In webAppCollection
Dim contentDbCollection As SPContentDatabaseCollection = _
webApp.ContentDatabases
For Each contentDb As SPContentDatabase In contentDbCollection
contentDatabases.Add(contentDb.Name)
Next
Next
End If

B.
Dim webAppCollection As SPWebApplicationCollection = _
SPWebService.ContentService.WebApplications
If Not (webAppCollection Is Nothing) Then
For Each webApp As SPWebApplication In webAppCollection
Dim contentDbCollection As SPContentDatabaseCollection = _
webApp.ContentDatabases
For Each contentDb As SPContentDatabase In contentDbCollection
contentDatabases.Add(contentDb.Server)
Next
Next
End If

C.
Dim webAppCollection As SPWebApplicationCollection = _
SPWebService.AdministrationService.WebApplications
If Not (webAppCollection Is Nothing) Then
For Each webApp As SPWebApplication In webAppCollection
Dim contentDbCollection As SPContentDatabaseCollection = _
webApp.ContentDatabases
For Each contentDb As SPContentDatabase In contentDbCollection
contentDatabases.Add(contentDb.Name)
Next
Next
End If

D.
Dim webAppCollection As SPWebApplicationCollection = _
SPWebService.AdministrationService.WebApplications
If Not (webAppCollection Is Nothing) Then
For Each webApp As SPWebApplication In webAppCollection
Dim contentDbCollection As SPContentDatabaseCollection = _
web App.ContentDatabases
For Each contentDb As SPContentDatabase In contentDbCollection
contentDatabases.Add(contentDb.Server)
Next
Next
End If



Leave a Reply 0

Your email address will not be published. Required fields are marked *