SharePoint problem connecting to DB2 when using DB2/Visual Studio 2010/Entity Framework/SharePoint 2010

Posted on 2011-10-21
Last Modified: 2012-05-12
I'm attempting to develop a simple Visual Studio 2010 SharePoint project which populates a SharePoint list from a single DB2 database table. Very basic. But it fails when I deploy the solution and attempt to view the list. And I looks to be failing regarding the connection string, but it may be failing in how I need to create the database connection; and how it should be done in this case I am unsure.

I do believe all my DB2 drivers and data providers are configured correctly. In VS I can connect to DB2 and build the Business Data Connectivity Model without a problem and see all the DB2 tables.

I think problem is that the DB2 connection string is stored in the app.config of the project. But I think, by design, the app.config is not part of the deployment to SP.

So, I am stuck trying to simply create the connection for the model to use once deployed to SP.

Perhaps my issue is with the connection string but I'm not really sure.

Any suggestions how I should be creating such a connection?

My cleansed app.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
    <add name="AgencyEntities" connectionString="metadata=res://*/AgencyModel.Agency.csdl|res://*/AgencyModel.Agency.ssdl|res://*/AgencyModel.Agency.msl;provider=IBM.Data.DB2;provider connection string=&quot;Database=DEV;User ID=user1;Password=12345;Server=dbserver:50000;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" />

Open in new window

(note: I have searched and searched for any example as to how I should perform the DB2 connection for an Entity when being used in an SP project.  I've found none so far.)
Question by:Dan-Aspitel

    Accepted Solution

    I think I found the answer.  

    It looks like this is not a problem limited to DB2, but is a common connectionString problem with BCS.

    See the section titled "Modifying the web configuration" at

    Here is an excerpt:
    Let’s focus firstly on the connection string problem. As suggested I’m going to put it into the Web-Application’s web.config file using the SPWebConfigModification class. The idea is to add an Event-Receiver for a particular Feature and while FeatureActivated is called insert the connection string as needed and at FeatureDeactivating cleanup and remove all modifications from web.config.

    Author Closing Comment

    Sample solution found.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now