1

I am trying to create a custom web part in SharePoint 2013 that connects to a SQL 2012 database.

I have gone as far as I can with the SharePoint BDC to connect to the external data. I am not able to use as a solution to create, update the remaining tables.

The tables I need to present and update have many to many relationships. Has anyone successfully done something like this in SharePoint. If so can you please share.

Or can someone point me to some good documentation/sample of setting up the database connection in Visual Studio custom web part project.

  • what's your web part should do ? – Mohamed El-Qassas MVP Apr 25 '17 at 17:54
  • Nothing yet :) But needs to provide data maintenance screens. – Moe Apr 26 '17 at 17:18
3

You have a few choices. One is to create a web service that does all the data access, and call the web service via the BDC. Another option is to avoid the BDC and connect to the DB directly. For the latter option, remember that a web part is just an asp.net component, and so you can use normal asp.net methods to connect to a database.

Of course, there are a few additional challenges, like figuring out where to store connection info, as discussed here.

  • I am looking into using a straight database connection. Is it feasible to build interface screens that would then update the database? – Moe Apr 26 '17 at 19:07
  • By interface screens, usually people create multiple web parts, and then add those parts to different pages. Another option is to create "application pages". (searching for "sharepoint application pages" or "sharepoint web parts" should get you started) – Mike2500 Apr 26 '17 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.