• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1017
  • Last Modified:

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

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.)
  • 2
1 Solution
Dan-AspitelAuthor Commented:
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 http://strepas.wordpress.com/2010/12/15/another-walkthrough-of-enabling-crud-bcs-for-sp2010/

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.
Dan-AspitelAuthor Commented:
Sample solution found.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now