Click here to Skip to main content
6,290,721 members and growing! (12,858 online)
Email Password   helpLost your password?
Enterprise Systems » SharePoint Server » General     Advanced License: The Code Project Open License (CPOL)

how to create a database connection for the Business Data Catalog in Microsoft Office SharePoint Server 2007

By Ranjitpl

An easy way to connect external database in sharepoint using Business Data Catalog
XML
Version:3 (See All)
Posted:6 Jan 2009
Views:5,850
Bookmarked:13 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
5 votes for this article.
Popularity: 2.94 Rating: 4.20 out of 5

1

2
2 votes, 40.0%
3

4
3 votes, 60.0%
5

Introduction

The Business Data Catalog feature of Microsoft Office SharePoint Server 2007 provides an easy way to integrate business data from back-end server applications. You register business data exposed in databases or through Web services in the Business Data Catalog by creating metadata that describes the database or Web service. The Business Data Catalog then uses this metadata to make the right calls into the data source to retrieve the relevant data. The objective of this article access the LOB application’s data through BDC and display it in the Sharepoint site inside the Business Data Lists Webpart. To generate LOB we can use different tools like Microsoft business Data Catalog Definition Editor for Microsoft office SharePoint server 2007 or BDCMetaMan.  The BDCMetaMan is not free but Microsoft business Data Catalog Definition Editor is free.

What is Problem with Microsoft business Data Catalog Definition?

When we generate LOB with Microsoft BDC Editor it does not generate Method instance “Finder” but it does not show up in the list when trying to add it to a Business Data list. We have to add “Finder” method instance to XML file manually. After adding “Finder” it will show BDC in Business Data type Picker. 

Start Writing the BDC Metadata in XML

Metadata is an XML file. Start writing xml, In this we start with LobSystem tag. LobSystem tag define the namespace , The name of the LOB System, the type of system Database or web service.

<LobSystemInstances>

 <LobSystemInstance Name="Test1" >

 <Properties>

 <Property Name="rdbconnection Data Source" Type="System.String">SMTSRV01</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>

Now, create an entity and define its properties.

 
 <Entity EstimatedInstanceCount="100" Name="Product">

 <Properties>

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

 </Properties>

 <Identifiers>

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

 </Identifiers>

There should be a method that gets the details of the entity based on the input parameters.  The following tags define a method called “FindProducts” which has a query tha t 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="FindProducts">

 <Properties>

 <Property Name="RdbCommandText" Type="System.String">

 SELECT ProductID, Name,Price 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="Price">

 <LocalizedDisplayNames>

 <LocalizedDisplayName LCID="1033">Price</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>

Now create an instance fof the “FindProducts” method..

 
<MethodInstances>

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

</MethodInstances>

The complete metadata code is as follows:

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

<LobSystem xmlns:xsi= href="http://www.w3.org/2001/XMLSchema-instance">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="Test" 
    xmlns="http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog">

 <LobSystemInstances>

 <LobSystemInstance Name="Test" >

 <Properties>

 <Property Name="rdbconnection Data Source" Type="System.String">ServerName</Property>

 <Property Name="rdbconnection Initial Catalog" Type="System.String">DataBaseName</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="FindProducts">

 <Properties>

 <Property Name="RdbCommandText" Type="System.String">

 SELECT ProductID, Name,Price 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="Price">

 <LocalizedDisplayNames>

 <LocalizedDisplayName LCID="1033">Price</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 writing LOB we have to Import this to Sharepoint web site.

  • Go to the central administration and select your SSP.

    SSP_small.JPG

  • Browse your metadata file and click “Import”

    Import_small.JPG

  • A warning message will come. Click “Ok”.

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

  • Click “Add a Web Part”
  • Select the “Business Data List” Web Part under Business Data and click Add
  • In the newly added Business Data List Web Part click Edit and select Modify Shared Web Part
  • In the type textbox, click Browse

    Tool.JPG

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

Now the Webpart will look like the following.

Display_small.JPG

History 

06/1/2009

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ranjitpl


Member
I am software engineer.I am working on Microsoft Technologies. Currently working in Asp.net,C#.net,Vb.net,DotNetNuke and Microsoft Office Sharepoint Server 2007 (MOSS). I am Microsoft Certified in Dot net Framework.
Occupation: Software Developer
Company: SmartBuzz
Location: India India

Other popular SharePoint Server articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralAwesome PinmemberVivek279420:35 6 Jan '09  
GeneralFantastic PinmemberManvindersingh19:07 6 Jan '09  
GeneralCool PinmvpAbhijit Jana18:56 6 Jan '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 6 Jan 2009
Editor: Sean Ewington
Copyright 2009 by Ranjitpl
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project