• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1010
  • 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"?>
<configuration>
  <connectionStrings>
    <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" />
  </connectionStrings>
</configuration>

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.)
0
Dan-Aspitel
Asked:
Dan-Aspitel
  • 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.
0
 
Dan-AspitelAuthor Commented:
Sample solution found.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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