Dotnetdreamer's Weblog

SharePoint, Silverlight and Azure

Posts Tagged ‘Microsoft Office Sharepoint Server 2007’

Creating Lists using Sharepoint Object Model

Posted by Ramprasad Navaneethakrishnan on May 26, 2009

In my previous post I wrote about creating sites using sharepoint object model. I strongly recommend to read that post before proceeding with this. It discusses about Sharepoint Site Architectures in detail.

Listed below are the Sharepoint site components and their corresponding object in the sharepoint object model.

Sharepoint Site Architecture Component Object in Sharepoint Object Model
Site Collection SPSite
Site SPWeb
List Collection SPListCollection
List SPList
List Field Collection SPFieldCollection
List Field SPField
List Item Collection SPListItemCollection
List Item SPListItem

Steps to create a new Sharepoint List:

  1. Open Visual Studio. Create a new Windows Forms project.
  2. Add a textboxes, one to accept the name of the site collection and another to accept the name of the new site to be created under the site collection.
  3. Add a button that creates the new site.
  4. Add reference to Microsoft.Sharepoint dll. This dll is represented by the name Windows Sharepoint Services in the Add Reference dialog box.
  5. Add the namespace of Microsoft.Sharepoint dll like this.
    • using Microsoft.Sharepoint;
  6. In the button click event, open the site collection.
    • SPSite siteCollection = new SPSite(txtSiteCollectionUrl.Text);
  7. Now open the top level site of the site collection.
    • SPWeb site = siteCollection.OpenWeb();
    • If you want to open a different site under the site collection other than the top level site, you can use the overloaded methods of the OpenWeb() method that accepts the name of the site as argument.
  8. The Lists property present in the SPWeb object will return all the lists that are present in that site as an SPListCollection object
    • SPListCollection listCollection = site.Lists;
  9. In order to add a new list, use the add method of the SPListCollection object.
    • listCollection.Add(“listname”, “list description”, SPListTemplateType.GenericList);
    • Note that the third argument accepts the template in which the list should be created. GenericTemplate represents the custom list. We can choose the template we need from the SPListTemplateType enum.
  10. Close and dispose and the site and site collection
    • site.dispose();
    • siteCollection.close();

The complete code can be found below..

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

SPSite siteCollection;
SPWeb site;

private void btnCreateSite_Click(object sender, EventArgs e)
{

try
{
siteCollection = new SPSite(txtSiteCollection.Text);
site = siteCollection.OpenWeb();
SPListCollection listCollection = site.Lists;

listCollection.Add(txtListName.Text, “list description”, SPListTemplateType.GenericList);
}
catch (Exception)
{ }
finally
{
site.Dispose();
siteCollection.Close();
}
}

}
}

Hope this is useful.

Posted in MOSS 2007 | Tagged: , , , , , , , , , , | 4 Comments »

Sharepoint Webparts

Posted by Ramprasad Navaneethakrishnan on May 9, 2009

Web part is what that makes up the web pages in a sharepoint site. A Sharepoint site is nothing but a group of web pages in which each and every web page holds one or more web parts which in itself contains different types of data based on the type of the web part chosen. The following are the out-of-the-box web parts available with MOSS 2007.

  1. Content Editor Web Part
  2. Form Web Part
  3. Image Web Part
  4. List Web Part
  5. Page Viewer Web Part
  6. Site Users Web Part
  7. XML Web Part

Lets see each of these web parts in detail.

  • Content Editor Web Part
    • Content Editor Web Part is used to display data in the form of text, images, table and links. To provide input to this web part, it exposes three properties in its tool pane (A web part’s tool pane can be reached by Site Actions –> Edit Page –>Click Edit in the web part–>Select Modify Shared Web Part ). Those are
      • Source Editor : Data is entered in HTML format. The data can be formatted using HTML tags and it requires author to know the HTML syntax.
      • Rich Text Editor :  Allows to enter information in plain text. It provides tools to insert images, tables and links into the web part.
      • Content Link : This can be used to link this web part to a text file with HTML formatting.
  • Form Web Part
    • Form Web Part needed a separate post and it can be read here.
  • Image Web Part
    • This Web Part is used to add an image to your web part page. The image can be a drawing or a logo or a diagram. The supported image formats are .bmp, .emf, .gif, .jpg, .png
    • The path of the image can be given in the Image Link property in the web parts tool pane
  • Page Viewer Web Part
    • This web part displays the content of any web page that is linked to it. In addition to web pages, it can display the contents of a folder or a file for which the path is provided in the toolpane.
    • There will be three radio buttons in the toolpane for each for Web Page, Folders and Files. The appropriate radio button should be checked and in the Link textbox, the path of the webpage, file or folder should be provided.
  • Site Users Web Part
    • This web part displays the list of users and groups who have access to the Sharepoint site. There are three two filter conditions that can be applied to customize the users / groups being displayed.
      • Number Of Items To Display : Restricts the number of items (users / groups) being displayed in this web part. The value ranges from 1 to 1000.
      • Display Type:
        • Display Users / Groups who have direct permission.
        • Display user’s belonging to this Site’s members group
        • Display users from this group . ( The needed group name can be entered in the text box provided)
  • XML Web Part
    • This web part displays XML formatted data and applied XSL Transformtions prior to the display of the data.
    • XML Editor and XSL editor properties present in the tool pane allows the user to enter the XML data and XSL transformations.
    • XML Link and XSL Link properties present in the tool pane allows the user to link to XML files and XSLT files present anywhere in the connected network.

Hope this is useful.

There is also a post on out-of-the-box site templates in MOSS 2007 here.

Thanks.

Posted in MOSS 2007 | Tagged: , , , , , , , , , | 2 Comments »

Changing Site Themes – Sharepoint

Posted by Ramprasad Navaneethakrishnan on May 9, 2009

On my previous posts, I wrote about Out-of-the-box Site templates and Creating custom templates

This post is on ‘Changing the Site Theme’ in a Sharepoint site.

  1. Goto Site Actions –> Site Settings
  2. Under the Look and Feel sections, select Site themes. The page will be shown like below.

 

sitethemes-sitesettings

 

sitethemes

3. On selecting various themes available in the list, a preview of the selected theme is shown on the left side.

4. Select the desired theme and select Ok to apply the theme

Posted in MOSS 2007 | Tagged: , , , , | Leave a Comment »

Introduction to Site Templates

Posted by Ramprasad Navaneethakrishnan on May 9, 2009

Sharepoint 2007 comes with some out-of-the-box site templates that allows Administrators or Information Workers to readily create sites by choosing one of the available templates that suites their requirement.

The out-of-the-box Site Templates available with Sharepoint 2007 are broadly classified into 4 categories as mentioned below.

  1. Collaboration
  2. Meeting
  3. Enterprise
  4. Publishing

Collaboration Templates

  • Team Site:
    • This site is for team members to collaborate on any tasks or projects. To facilitate this type of collaboration, it includes the following webparts
      • Document library : To manage documents associated with the task / project
      • Announcement List : Create / Manage announcements with the project team
      • Discussion Board : A forum to discuss on tasks / issues assocaited with the project
      • Calendar Lists : Keeps track of the various schedules associated with team members / project
      • Task Lists : A list that keeps track of task items assigned against members of the project
      • Links : A single place to keep track of  links to sites that are needed for the project

 

teamsite

  • Blank Site:
    • As the name suggests, its just a blank site with no webparts populated by default. This is a good place for building a fully customized site.

 

blanksite

Document Workspace:

  • This template is suitable for a team documentation project or a team of technical writers where there is a need in creation and modification of common documentation.
  • It has the following webparts associated with it.
    • Document Library
    • Tasks List
    • Links

 

documentworkspace

  • Blog Site:
    • A site for a team or person to post ideas and observations which site visitors can comment to.

Meeting Templates

Basic Meeting:

  • A general purpose meeting template that helps to plan, organize and capture the results of the meeting using the following webparts associated with the site
    • Objectives list
    • Attendies
    • Agenda
    • Document Library

basicmeeting

  • Blank Meeting:
    • A blank meeting site that can be customized to suite the requirement
  • Decision Making Meeting:
    • This template is suitable when the purpose of the meeting is to reivew doucments, lists and other informations in order to make a decision. The webparts included are
      • Objectives list
      • Attendies
      • Agenda
      • Document Library
      • Tasks List
      • Decision List

decisionmeeting

 

  • Social Meeting:
    • This template comes handy when organizing a team picnic or party.  The web elements included are
      • Attendies list
      • Directions
      • Image Log
      • Thing to bring List
      • Photo Library
  • MultiPage Meeting:
    • This is similar to Decision Making template but it is designed to accomodate complex decision process. This site comes with two webpages by default and it can accomodate upto 10 individual pages. It includes
      • Objective Lists
      • Attendies Lists
      • Agenda

Enterprise

Enterprise templates are normally used as a top-level or high-level sites in an organizations site collection. It facilitated enterprise level activities in the areas of document management, records management and report management

  • Document Center:
    • A Site to centrally manage enterprise level documents. It has several document management features enabled by default like Major / Minor versionaing, Require check out etc. This templates includes the following webparts.
      • Document Library
      • Relevant documents
      • Upcoming tasks
      • Treeview webpart
  • Records Center:
    • This site template is used to centrally manage organizations data and data sources. The webparts included are
      • Records vault
      • Records routing list
      • Information management policy
      • Unassigned Records library

recordscenter

 

  • Site Directory:
    • A site template for listing, categorizing important sites in the organizations site collection. The webparts included are
      • Categorized Sites
      • Top Sites
      • Site Map
  • Report Center:
    • This site template as part of Sharepoint business intelligence solution communicates metrics, goals, statues and business intelligence informations by means of the foll0wing web elements
      • Dashboards
      • KPI indicators
      • Webpages

reportcenter

 

  • Search Center:
    • A site that enables users to seach for information. It includes webparts
      • SearchResults
      • Advanced Search
  • Search Center with tabs:
    • This is similar to search center except it comes with two tabs. One tab to search through information in the sites and the other tab ‘people’ that enables to search through peoples.

Publishing

  • News Site:
    • A site for publising news articles and links to news articles. The default webparts includes
    • Sample news page
    • Archive for storing older news

Hope this is useful.

A post on creating custom templates can be found here

Thanks.

Posted in MOSS 2007 | Tagged: , , , , , , , , , , , , , , , , , | 2 Comments »

Retrieving SharePoint List Data using CAML

Posted by Ramprasad Navaneethakrishnan on February 9, 2009

Lets see how to retrieve data from a SharePoint list and display it in a Web Part.

Scenario:

We have a SharePoint custom list with the name ‘MySPList’ which has the following columns.Title, AssignedTo and Status. We want to get all the data from the list for which AssignedTo has a value of ‘Ramprasad’.

CAML Query:

For the above scenario, the CAML query should look like the following..

<Where><Eq><FieldRef Name=’AssignedTo‘/><Value Type=’Text‘>Ramprasad</Value></Eq></Where>

Note here that in SharePoint list, ‘AssignedTo’ column is of type ‘Single Line of  Text’. The corresponding type in CAML is ‘TEXT’ which is mentioned in the CAML query.

Query Execution:

SPList mylist = web.Lists[“MySPList”];
SPQuery query = new SPQuery();
query.Query = “<Where><Eq><FieldRef Name=’AssignedTo’/><Value Type=’Text’>Ramprasad</Value></Eq></Where>”;
SPListItemCollection items = mylist.GetItems(query);

This statement execute the CAML query and stores the results as SPListItemsCollection object.

Loop through the results:

Now loop though the SPListItemsCollection object and get the needed column data .

foreach (SPListItem item in items)
{
DataRow _row = _table.NewRow();
_row[0]  = SPEncode.HtmlEncode(item[“Title”].ToString());
_row[1] = SPEncode.HtmlEncode(item[“AssignedTo”].ToString());
_row[2] =  SPEncode.HtmlEncode(item[“Status”].ToString());
_table.Rows.Add(_row);
}

Step by Step:

1. Open Visual Studio 2008. File -> New -> Project.

2. Select WebPart project template from Sharepoint project type.

3. Copy paste the following code

using System;
using System.Data;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace SharePointListDataRetrival
{
[Guid(“7594e58f-eceb-4fce-84b9-e5ce7424aa67”)]
public class SharePointListDataRetrivalWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
DataSet _listData;
public SharePointListDataRetrivalWebPart()
{
}

protected override void CreateChildControls()
{
base.CreateChildControls();
DataGrid dgSpListData = new DataGrid();
dgSpListData.DataSource = GetListData();
dgSpListData.DataBind();
this.Controls.Add(dgSpListData);
}

private DataSet GetListData()
{
_listData = new DataSet();
DataTable _table = new DataTable();
DataColumn dc = new DataColumn(“Title”);
_table.Columns.Add(dc);
dc = new DataColumn(“AssignedTo”);
_table.Columns.Add(dc);
dc = new DataColumn(“Status”);
_table.Columns.Add(dc);
using (SPWeb web = SPContext.Current.Site.RootWeb)
{

SPList mylist = web.Lists[“MySPList”];
SPQuery query = new SPQuery();
query.Query = “<Where><Eq><FieldRef Name=’AssignedTo’/><Value Type=’Text’>Ramprasad</Value></Eq></Where>”;
SPListItemCollection items = mylist.GetItems(query);
foreach (SPListItem item in items)
{
DataRow _row = _table.NewRow();
_row[0]  = SPEncode.HtmlEncode(item[“Title”].ToString());
_row[1] = SPEncode.HtmlEncode(item[“AssignedTo”].ToString());
_row[2] =  SPEncode.HtmlEncode(item[“Status”].ToString());
_table.Rows.Add(_row);
}
}
_listData.Tables.Add(_table);
return _listData;
}
}
}

4.  Project Properties -> Debug -> Under ‘Start Action’ section,Select ‘Start browser with url’ -> Give the name of your sharepoint site. Eg : http://vm:1002

5. Build the project.

6. Deploy the solution

7. Open SharePoint site. Site Settings -> Edit Page -> Add New WebPart -> Locate your webpart by the name – >Select Ok.

Now, you will be now able to see the SharePoint list data in your webpart.

Let me know your comments. Thanks.

Posted in MOSS 2007 | Tagged: , , , , , , , , , | 32 Comments »

Business Data Catalog in MOSS 2007

Posted by Ramprasad Navaneethakrishnan on September 26, 2008

Overview

As per Microsoft, Business Data Catalog (BDC) is a “new business integration feature available in Microsoft Office Sharepoint Server 2007. It is a shared service and it enables MOSS 2007 to surface business data from back-end server applications without any coding.”

Why BDC?

All the data entered into the Sharepoint system gets stored in the content database of that particular Sharepoint application. So by default, a Sharepoint site will get information from its content database. But it is quite natural for an organization to have information stored in multiple databases by numerous applications throughout the organization. For example, inventory software stores its data in a database that is different from a CRM software storing data in a database. But people will find is extremely useful if provided with a space where they can have every bit of information from each and every department in the organization ranging from the up-to-minute logistics information to the up-to-date sales analysis. The BDC feature of Microsoft Office Sharepoint Server 2007 provides the needed business integration for integrating the line of business (LOB) applications with the Sharepoint.

What is BDC?

Business Data Catalog provides built in support for displaying data from two data sources.

·         Databases

·         Web Services

Microsoft promises a “no coding” approach for integrating LOB applications with Sharepoint. Business Data Catalog provides access to the data sources through a metadata model that provides a consistent and simplified client object model. So it is the metadata authors who describe the API of the business applications in xml. After this, the administrators will associate this metadata with the Sharepoint application after which the LOB data is available in the Sharepoint system.

 


Development Environment

The walkthrough below will guide in developing a simple BDC application in MOSS 2007. The following states the database and MOSS settings used by this walkthrough.

MOSS Settings

·         Microsoft Office Sharepoint Server 2007 Enterprise Edition Installed.

o   Standard Edition of MOSS 2007 does not have BDC feature

·         Created a new web application named “KnowMax-1234” from Central Administration.

·         Use the default Shared Services Provider (SSP) associated with the created web application or create a new SSP for the web application KnowMax-1234.

Database details of LOB application

·         Database Server : TARGETMC-VM\SQLEXPRESS

·         Database Name : Test

·         Table Name : dbo.Product

·         Snapshot of the LOB Database :

 

Walkthrough:  Creating a product BDC from LOB database

Objective

The objective of this walkthrough is, “To access the LOB application’s data through BDC and display it in the Sharepoint site inside the Business Data Lists Webpart.” This Webpart will get the ‘ProductID’ as input from the user and gets the corresponding product details from the LOB database. The following is the snapshot of the output.

 

 

 

The “ProductID” is given as 1. And the product detail for this product id is obtained from the LOB database.

 

Authoring Metadata

Authoring the metadata forms the heart of the development process involved in creating the BDC application. Though there are many tools that promises to simplify this process, most of them are ambiguous or non freewares. Some of those tools are

·         Microsoft Business Data Catalog definition editor

o   Gets shipped with the Sharepoint 2007 SDK which is available free for download

·         Metaman

o   Metaman is supposedly good but it comes with a cost as Metaman is not a freeware

 

So avoiding all those ambiguities, let us start writing the BDC metadata in xml. To start of the process, open a notepad and follow the steps below

1.    Since the metadata is an xml file, it starts off with the following lines just like all xml documents

<?xml version=1.0 encoding=utf-8 standalone=yes?>

2.    The LobSystem tag defines the namespaces, the name of the LOB system, the type of the system (Database or Webservice) and the version of the system

<LobSystem xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog BDCMetadata.xsd Type=Database Version=1.0.0.0 Name=ProductBDC1

xmlns=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog>

3.    Then create a new instance for this Lob system using the following lines

<LobSystemInstances>

<LobSystemInstance Name=ProductBDC1 >

4.    Define the database, connection and authentication properties of the Lob system using the properties tag.

<Properties>

        <Property Name=rdbconnection Data Source Type=System.String>TARGETMC-VM\SQLEXPRESS</Property>

        <Property Name=rdbconnection Initial Catalog Type=System.String>Test</Property>

        <Property Name=rdbconnection Integrated Security Type=System.String>SSPI</Property>

        <Property Name=DatabaseAccessProvider Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAccessProvider>SqlServer</Property>

        <Property Name=AuthenticationMode Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAuthenticationMode>PassThrough</Property>

        <Property Name=RdbConnection Pooling Type=System.String>false</Property>

      </Properties>

    </LobSystemInstance>

</LobSystemInstances>

5.    Now, create an entity and define its properties

  <Entities>

    <Entity EstimatedInstanceCount=100 Name=Product>

      <Properties>

<Property Name=Name Type=System.String>Name</Property>

      </Properties>

      <Identifiers>

   <Identifier Name=ProductID TypeName=System.String /></Identifiers>

These tags define the entity called Product and its two members, Name and ProductID.

6.    There should be a method that gets the details of the entity based on the input parameters.  The following tags define a method called “GetProducts” which has a query that gets the name and productid of the products entity based on the entered productid. Also the input parameter is defined using the parameter tag with Direction attribute as “In”. The output is the product entity having two members namely name and productid which is defined in the parameter tags with the Direction attribute as “Return”.

      <Methods>

        <Method Name=GetProducts>

          <Properties>

            <Property Name=RdbCommandText Type=System.String>

              SELECT ProductID, Name FROM Product WHERE ProductID = @ProductID

           </Property>

            <Property Name=RdbCommandType Type=System.Data.CommandType>Text</Property>

          </Properties>

          <FilterDescriptors>

            <FilterDescriptor Type=Comparison Name=ProductID>

              <Properties>

                <Property Name=Comparator Type=System.String>Equals</Property>

              </Properties>

            </FilterDescriptor>

          </FilterDescriptors>

          <Parameters>

            <Parameter Direction=In Name=@ProductID>

              <TypeDescriptor TypeName=System.String IdentifierName=ProductID AssociatedFilter=ProductID Name=ProductID>

                <DefaultValues>

                  <DefaultValue MethodInstanceName=ProductFinderInstance Type=System.String > 1 </DefaultValue>

                </DefaultValues>

              </TypeDescriptor>

            </Parameter>

            <Parameter Direction=Return Name=Products>

              <TypeDescriptor TypeName=System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

IsCollection=true Name=ProductDataReader>

              <TypeDescriptors>

                <TypeDescriptor TypeName=System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

                                Name=ProductDataRecord>

                  <TypeDescriptors>

                    <TypeDescriptor TypeName=System.String IdentifierName=ProductID Name=ProductID>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>ProductID</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                    </TypeDescriptor>

                    <TypeDescriptor TypeName=System.String Name=Name>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>Name</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                      <Properties>

                        <Property Name=DisplayByDefault Type=System.Boolean>true</Property>

                      </Properties>

                    </TypeDescriptor>

                  </TypeDescriptors>

                </TypeDescriptor>

              </TypeDescriptors>

              </TypeDescriptor>

            </Parameter>

 </Parameters>

7.    Then create an instance for the “GetProducts” method like this.

<MethodInstances>

            <MethodInstance Name=ProductFinderInstance Type=Finder ReturnParameterName=Products />

          </MethodInstances>

 

The complete metadata definition xml is as follows. Copy it into a notepad and save as “ProductBDC.xml”.

<?xml version=1.0 encoding=utf-8 standalone=yes?>

<LobSystem xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog BDCMetadata.xsd Type=Database Version=1.0.0.0 Name=ProductBDC1 xmlns=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog>

  <LobSystemInstances>

    <LobSystemInstance Name=ProductBDC1 >

      <Properties>

        <Property Name=rdbconnection Data Source Type=System.String>TARGETMC-VM\SQLEXPRESS</Property>

        <Property Name=rdbconnection Initial Catalog Type=System.String>Test</Property>

        <Property Name=rdbconnection Integrated Security Type=System.String>SSPI</Property>

        <Property Name=DatabaseAccessProvider Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAccessProvider>SqlServer</Property>

        <Property Name=AuthenticationMode Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAuthenticationMode>PassThrough</Property>

        <Property Name=RdbConnection Pooling Type=System.String>false</Property>

      </Properties>

    </LobSystemInstance>

  </LobSystemInstances>

  <Entities>

    <Entity EstimatedInstanceCount=100 Name=Product>

      <Properties>

        <Property Name=Name Type=System.String>Name</Property>

      </Properties>

      <Identifiers>

        <Identifier Name=ProductID TypeName=System.String />

      </Identifiers>

      <Methods>

        <Method Name=GetProducts>

          <Properties>

            <Property Name=RdbCommandText Type=System.String>

              SELECT ProductID, Name FROM Product WHERE ProductID = @ProductID

            </Property>

            <Property Name=RdbCommandType Type=System.Data.CommandType>Text</Property>

          </Properties>

          <FilterDescriptors>

            <FilterDescriptor Type=Comparison Name=ProductID>

              <Properties>

                <Property Name=Comparator Type=System.String>Equals</Property>

              </Properties>

            </FilterDescriptor>

          </FilterDescriptors>

          <Parameters>

            <Parameter Direction=In Name=@ProductID>

              <TypeDescriptor TypeName=System.String IdentifierName=ProductID AssociatedFilter=ProductID Name=ProductID>

                <DefaultValues>

                  <DefaultValue MethodInstanceName=ProductFinderInstance Type=System.String > 1 </DefaultValue>

                </DefaultValues>

              </TypeDescriptor>

            </Parameter>

            <Parameter Direction=Return Name=Products>

              <TypeDescriptor TypeName=System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

                              IsCollection=true Name=ProductDataReader>

              <TypeDescriptors>

                <TypeDescriptor TypeName=System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

                                Name=ProductDataRecord>

                  <TypeDescriptors>

                    <TypeDescriptor TypeName=System.String IdentifierName=ProductID Name=ProductID>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>ProductID</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                    </TypeDescriptor>

                    <TypeDescriptor TypeName=System.String Name=Name>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>Name</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                      <Properties>

                        <Property Name=DisplayByDefault Type=System.Boolean>true</Property>

                      </Properties>

                    </TypeDescriptor>

                  </TypeDescriptors>

                </TypeDescriptor>

              </TypeDescriptors>

              </TypeDescriptor>

            </Parameter>

          </Parameters>

          <MethodInstances>

            <MethodInstance Name=ProductFinderInstance Type=Finder ReturnParameterName=Products />

          </MethodInstances>

        </Method>

      </Methods>

    </Entity>

  </Entities>

</LobSystem>

 

After authoring the metadata for the Lob system, we have to just associate this with a web application to make use the BDC.

 

1.    Go to the central administration and select your SSP.

2.    Under Business Data Catalog, click Import application definition

 

 

3.      Choose your metadata file and click “Import”

 

 

 

4.       A warning message will come. Click “Ok” as of now.

5.      You can see your imported application by clicking “View Application” under Business Data Catalog for your SSP

 

 

6.      Now, go to your Sharepoint site and click “Edit Page” under Site Actions

7.      Click “Add a Web Part”

8.      Select the “Business Data List” Web Part under Business Data and click Add

 

 

 

9.      In the newly added Business Data List Web Part click Edit and select Modify Shared Web Part

 

  10.  In the type textbox, click Browse

 

 

 

 

 

 

 

 

 

11.  In the Business Data Type Picker dialog box, select your BDC file and click Ok.

 

 

12.  Click Ok in the business data list properties window (screen shot in step 10.)

13.  Now the Webpart will look like the following.

 

 

 

 

14.  Enter 1 in the productid textbox and click “Retrieve Data”.

15.  The product name associated with the product id in the LOB database gets retrieved like the following.

 

 

Posted in MOSS 2007 | Tagged: , , , , , , , , , | 5 Comments »