Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

Posts Tagged ‘edit’

CRUD and BCS

Posted by JP on September 30, 2012

In this article we can experiment with BCS by connecting to an external database. After completing this article you will be able to:

· View Database Table inside SharePoint

· Perform Add/Edit/Delete operations

Following are the activities involved.

1. Create database and table

2. Using SharePoint Designer create BCS External Content Type

3. Using SharePoint Designer create Add/Edit/Delete operations metadata

4. Using SharePoint Designer create Lists & Form

5. Using Central Administration set Permissions for external Content Type

1. Create database and table

Create a database and table named Customer with following fields:

clip_image002

Add some data into it:

clip_image004

2. Using SharePoint Designer create BCS External Content Type

Now we can create an External Content type using SharePoint Designer. Start the Designer application and open our SharePoint web site > External Content Types as shown below.

clip_image006

Click on the External Content Type button from the top side. In the appearing window change the Name and Display Name (click on the links) as shown below.

clip_image008

Now click on the External System link and you will get the following dialog.

clip_image010

Click on the Add Connection button and select SQL Server in the appearing dialog.

clip_image012

In the appearing connection details dialog, enter your server details.

clip_image014

Click the OK button and your server connection is ready.

3. Using SharePoint Designer create Add/Edit/Delete operations metadata

From the appearing tables list select the Customer table and right click to get the context menu. Use the Create All Operations menu item to get the Add/Edit/Delete operations wizard.

clip_image016

Click on the Finish button in the appearing wizard.

clip_image018

Click on the Save button from the top tool bar.

clip_image020

4. Using SharePoint Designer create Lists & Form

Now the operations are ready and we need to create the List Form and the associated Add/Edit/Delete forms inside SharePoint.

clip_image022

From the toolbar, click on the Create Lists & Form button as highlighted above. In the appearing dialog box enter the name for the List and click the OK button as shown below.

clip_image024

Wait for a while and your List page will be ready.

clip_image026

5. Using Central Administration set Permissions for external Content Type

Now you can try viewing the Customer Data list inside SharePoint.

clip_image028

On clicking the list, you will be seeing an “Access Denied by Business Data Connectivity” error message. To resolve this we need to set permission for the External Content Type.

Open the SharePoint Central Administration website. Click on Manage Service Applicatoins.

clip_image030

In the appearing page click on the Business Data Connectivity Services link as shown below:

clip_image032

In the appearing list, hover over the Customer Data item and click on the Set Permissions menu item as shown below.

clip_image034

You will get the following dialog.

clip_image036

Enter the user name, click the Add button and check all permissions. Click the OK button to close the wizard. (Make sure you are adding the username used to view SharePoint)

Now you are ready with the Permissions. Go back to the SharePoint > Customer Data list and you will be able to see the data as shown below.

 

Now you can try playing with the View/Edit/Delete features of the BCS list.

References

http://www.zimmergren.net/technical/access-denied-by-business-data-connectivity-solution

Summary

In this article we have seen how to create an External Content Type through Business Connectivity Services and view it inside SharePoint. In the real world scenario using BCS we can connect to WCF Services and other Business Applications like Microsoft CRM to view/update data inside SharePoint.

Advertisements

Posted in SharePoint | Tagged: , , , , , , | 2 Comments »

How to edit app.config file?

Posted by JP on January 13, 2011

The application configuration file provides flexibility in reading application settings.  But once in a while it is needed to change the settings programmatically. 

We can see how it is made possible.

Step 1: Create new Windows Forms application

Create a new windows forms application and add a config file into it.

Step 2: Add reference to System.Configuration

Add reference to System.Configuration namespace

Step 3: Add code to edit config

System.Configuration.Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            configuration.AppSettings.Settings.Remove(“font”);
            configuration.AppSettings.Settings.Add(“font”, “Calibri”);

            configuration.Save(ConfigurationSaveMode.Modified);

Summary

For editing an existing appSettings key – we have deleted and added the key.

Posted in WinForms | Tagged: , , , , | Leave a Comment »