13.07.2015 Views

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

452CHAPTER 11 ■ PROGRAMMING SHAREPOINT SERVICES4. In the Templates w<strong>in</strong>dow, select W<strong>in</strong>dows Application.5. Name the new project Site Explorer and press the OK button.6. When the new project is open, drop a TreeView control onto Form1.7. Open the code w<strong>in</strong>dow for Form1.vb and add the follow<strong>in</strong>g statements:Imports SystemImports System.Data.SqlClientImports System.NetImports System.xmlAdd<strong>in</strong>g the Web ReferenceThis project makes use of the Webs web service to return <strong>in</strong>formation about sites and webs. Inthis section, you will set a reference to this web service. It does not matter which site you referencewhen sett<strong>in</strong>g up the service, because we will change it <strong>in</strong> code later.Follow these steps to set the web reference:1. In Visual Studio, select Project ➤ Add Web Reference from the menu.2. In the Add Web Reference dialog, type http://vsmoss/sites/<strong>in</strong>tranet/_vti_b<strong>in</strong>/Webs.asmx?WSDL and press the Go arrow.3. When the Webs web service is located, type MOSSService <strong>in</strong> the Web Reference Namebox and push the Add Reference button.Return<strong>in</strong>g All SitesBefore we can create the hierarchical view of the <strong>SharePo<strong>in</strong>t</strong> <strong>in</strong>stallation, we must return theset of all sites that are conta<strong>in</strong>ed <strong>in</strong> the <strong>in</strong>stallation. In this exercise, you will retrieve this<strong>in</strong>formation directly from the <strong>SharePo<strong>in</strong>t</strong> configuration database. Go<strong>in</strong>g directly aga<strong>in</strong>st the<strong>SharePo<strong>in</strong>t</strong> databases can be a dangerous technique if you are do<strong>in</strong>g more than read<strong>in</strong>g data;however, it’s handy to know that you can do it safely to retrieve <strong>in</strong>formation. Add the codefrom List<strong>in</strong>g 11-18 to return the top-level sites and add them to the tree.List<strong>in</strong>g 11-18. Return<strong>in</strong>g Top-Level SitesPrivate Sub Form1_Load_1(ByVal sender As System.Object, _ByVal e As System.EventArgs) Handles MyBase.LoadDim strConnection As Str<strong>in</strong>g = "Integrated Security=SSPI;➥Initial Catalog=WSS_Content;Data Source=VSSQL"Dim strSql As Str<strong>in</strong>g = "SELECT Title, FullUrl FROM dbo.Webs➥WHERE (ParentWebId IS NULL) AND (FullUrl '')➥AND (FullUrl IS NOT NULL) ORDER BY Title"Try

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!