When building SharePoint 2010 web parts, I have stumbled across the fact that there are really no easy ways to add a configuration file such as a web.config or an app.config. So I decided to add a new project to my solution that I will eventually detach. I expect it to build as a .DLL file and I can package it up with all of my solutions. It will contain my connection string (with no passwords of course), also URL’s etc…
I hope to find a better way of doing this, but for now I think this is really the way to go. You can eventually swap out .DLL’s for use when testing, or switching environments.
Additionally, here is another way. You can add the configuration to the root SharePoint site’s web.config file. Reference this link for further instructions.
If you come up with any better ways, I would like to hear about them. For now, this is the safest way and most secure way.