In this article I am going to explain how we 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.
create a sample sql database
Create a new database in SQL Server and filled it with some example data. In my case, this is the data in my SQL database, called sampleBDCData:
In this sample database, I've added a table called Student:
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:
Creating an external content type
The most effective and easy way to set up a simple BCS connection is to use SharePoint Designer 2010. In order to do this, we need to create a new External Content Type.
Here's how do create our External Content Type and attach it up with our database, step by step:
- Open the site you want to work with using SharePoint Designer 2010
2. Select "External Content Types" in the left hand navigation.
3. Click to create a new External Content Type as shown in the figure below:
4. Click the link: "Click here to discover external data sources and define operations":
5. Click "Add Connection"
6. Select "SQL Server" as your Data Source Type:
7. Enter the details about your connection to your SQL Server:
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":
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 Student_ID as an Identifier:
11. Click "Finish"
12. You'll be presented with a list of operations that your External Content Type can do, as shown in the below figure:
13. Save it.
Creating an external list
1. Open your site and choose Site Actions à More Options…
2. Select the External List template, and click Create
3. Enter a name for your list, e.g. StudentList
4. You'll see a field in this list called External Content Type, click the browse-button:
5. Select your data source and click OK:
configure the bdc access rights
1. Open Central Administration page, and click on Manage service application.
2. Click on Business Data Connectivity Service.
3. Open the context menu of the External Content type (i.e. CustomBDCData in this example). Click on Set permissions.
4. Add account (Group, or User) and assign the permissions.
5. Set appropriate permission to the BDC object. Remember that BDC object permission rules the interaction between user and external data source through BDC object.
6. Click OK.
You should now be able to access the external list as shown below:
Let's we add a new student in our external list (i.e. StudentList):
After adding a student, your list will be as follows: