So, I have a web part that needs to connect to a different database other than sharepoint. This is a custom web part that I'm writing in VS, not something built with SPD. How can I connect to the external database?
|
I believe Steve hit it on the head. Write your web part as you normally would using OLEDB or ODBC to make the connection to your DB and interact accordingly. Then store your password and connection string in the web.config of the SharePoint WFE(s). You should use WebConfigurationManager to access the web.config and pull the appropriate keys out of it to use in your script. This way if your enterprise requires annual password changes (or similar) you don't need to recompile and redeploy your code every time the password changes. Additionally, be sure to encrypt the applicable nodes of your web.config after you store your passwords there. You should never store plain text credentials in a web.config (or any configuration file for that matter). See http://msdn.microsoft.com/en-us/library/dtkwfdky.aspx for more information. |
|||||||
|
|
Just write it how you would in a normal ASP.NET webpart or application. You can store the connection string in the sharepoint web.config. |
|||
|
|