search blog
most popular
MCP MCTS MCT MVP

SPS 2010: Getting started with Business Connectivity Services (BCS) in SharePoint 2010 

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

Article 1 in the small BCS-series:

1. SP 2010: Getting started with the Business Connectivity Services (BCS)
2. SP 2010: Programmatically work with External Lists (BCS) in SharePoint 2010
3. SP 2010: Programmatically work with External Lists (BCS) using the Client Object Model

BCS in SharePoint 2010 is an awesome refinement of the Business Data Catalog from MOSS 2007. With BCS - or Business Connectivity Services - you get the possibility to connect external data and work with it from SharePoint.

In this article I will not cover the basics of what BCS is all about (MSDN/TechNet does this very well) - I will rather give you a walkthrough of how you can setup a BCS connection to an external database, and then work with this information directly from a SharePoint list - without the user actually knowing anything about the connection to the database.

BCS Poster: Business Connectivity Services Poster
BCS Team Blog: http://blogs.msdn.com/bcs/

A sample SQL database

I'll just show you how my sample database is set up - simply create a new database in your SQL Server and have it filled with some example data. In my case, this is the data in my SQL database, called Zimmergren_DB:
image

In this sample database, I've added a table called ProductList which in theory will represent some products in this database, like this:
image

I'm filling the database with some sample data, so we will be familiar with this data when we later watch this information from SharePoint:
image

Alright - we have some sample data in our SQL Server. Nothing fancy, just some very simple data. Great, let's get going with the fun stuff!

Creating an external content type

The most effective and easy way to set up a simple BCS connection, is to use SharePoint Designer 2010. You heard me, we can now get up and running with BCS by using SPD instead of modeling complex ADF files and things like that.

In order to do this, we need to create a new External Content Type!

Here's how do create our External Content Type and hook it up with our database, step by step:

  1. Open the site you want to work with using SharePoint Designer 2010
  2. Select "External Content Types" in the left hand navigation:
    image
    Loading this page might take some time, be patient!
  3. Click to create a new External Content Type like this:
    image
  4. Click the link that reads: "Click here to discover external data sources and define operations":
    image
  5. Click "Add Connection"
    image
  6. Select "SQL Server" as your Data Source Type:
    image
  7. Enter the details about your connection to your SQL Server:
    image
  8. When the connection is made, your Data Source Explorer will be filled with the database you have specified. Now choose the table you want to work with, and right-click and select "Create All Operations":
    image 

    You'll be presented with a wizard-like dialog where you can specify the operations, elements and other properties for your BCS connection.
  9. Click "Next" to get to the Parameters page
  10. Select the field that you want to act as an Identifier. In my case I've selected my ProductID just to get on with it:
    image
  11. Click "Finish"
  12. You'll be presented with a list of operations that your External Content Type can do, like this:
    image

That's it. A few points, a few clicks - and you're done. Let's create an external list (using the Browser to show how simple it is..) and hook up our external content type with it!

Creating an external list

There's a few ways to create an external list in SharePoint 2010. We will create it using the Browser UI to show you how simple it can be.

  1. Open your site and choose Site Actions - More Options…
    image
  2. Select the External List template, and click Create
    image
  3. Enter a name for your list, e.g. Product List
  4. You'll see a field in this list called External Content Type, click the browse-button beside it:
    image

    What is really awesome here, is that you're now presented with a dialog where you simply can choose the data source for this list. That means, you'll select the data source you've created (mine is called Zimmergren_DB). Then your list will automatically work against the SQL database, but still have the look and feel of a SharePoint 2010 list.
  5. Select your data source and click OK:
    image
  6. Now simply click the button called Create:
    image

Would you look at that! You're now working with external data, from your (what looks to be) normal SharePoint list! This is brilliant!

You now have the ability to create new items, update existing items, delete items and do all your normal CRUD-operations (CRUD = Create, Read, Update, Delete) straight from the SharePoint 2010 list.

Proof of concept - Adding a new product

Let's just for the fun of it add a new product called "Awesome Product 1.0" like the following screenshot:
image

Now go to your SQL Server and see the changes take effect immediately. The data is NOT stored in SharePoint, it's stored in your SQL Database.

This is what my table now looks like in the SQL Server, after adding a new item in the SharePoint list:
image

Summary

With a few points, followed by a few clicks - you've set up your external data connection. Basically it's that simple.

Of course there's a lot of things to consider when doing these configurations - and you might not want to auto-generate the CRUD-operations, but rather create them one by one and specify more fine-grained permissions etc.

This is merely a sample to show you how easy it is to actually get up and running with the SharePoint 2010 Business Connectivity Services (BCS) and work with external data!

Enjoy

 
Posted on 18-Jan-10 by Tobias Zimmergren
11 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
Tags: 2010, BCS, BDC, SP2010, How To
 

Links to this post (Trackbacks/Pingbacks)

Comments

Monday, 18 Jan 2010 09:16 by Roger
i tried this just now, but with the adventue-database. works very easyly. very nice to take spd10 and just click and then its done :) thank you again for great articles

Monday, 18 Jan 2010 09:20 by Christoffer von Sabsay
Great article! Any thoughts on how to deal with caching, logging and performance monitoring when doing a connection directly to a SQL data source? I think it might be a good idea to wrap the call to the db in a WCF service that takes care of caching, logging and stuff like that. A custom .NET assembly is another option, but then you would loose the ability to sync to the client. Any thoughts on this?

Tuesday, 19 Jan 2010 04:38 by Dimitrij Vasko
ur explanations makes it very simply to understand. short, many images, to point. very thanks for this!!

Tuesday, 19 Jan 2010 07:30 by
can it be plugged into SSO as previous BDC version?

Wednesday, 20 Jan 2010 03:01 by Figge
Bra skrivet. Precis vad vi behöver för våra tester vi ska göra på SP 2010 nu. Jag ringer dig i veckan om detta!

Thursday, 21 Jan 2010 04:56 by Yvan
Good article! thanks. My question/comment is around parameters when instead of using/creating the default operations of the content types, you want to use custom stored procedures for the CRUD operations?, I've done the Read List with my own stored procedure, however the parameter for inserts and updates are a bit confusing to me.. Any thoughs?

Wednesday, 27 Jan 2010 01:30 by Ola Axelsson
Is there any way to specify an SQL query with Joins in SharePoint Designer or need to then use VS 2010?

Friday, 12 Feb 2010 10:03 by lvm77
Good article! But if someone just could tell me if it's possible to create BCS connecting to Sybase 15.0 So far struggling unsuccessfully.

Wednesday, 24 Feb 2010 07:56 by

Name:
URL:
Email:
Comments: