Page 1 of 1

Connection Strings to databases

Posted: Thu Jul 17, 2008 2:41 pm
by Harley
I have been reading around on this. I have to do work on someone elses able install. I have downloaded the db to my machine. I am trying to change the connection string to it via the admin panel. The connection string is legitimate, other apps can hit the db. Able can not. I tried to change the string, i tried to de crypt it, but that does not work. When you just decrypt it, the save fails on the following line.

Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

The app path variable is wrong.

So how do i get around this?

I want to just change out the strings in the config file, but those had to be encrypted.

Re: Connection Strings to databases

Posted: Thu Jul 17, 2008 2:48 pm
by nickc
On my dev system, I just wrote the App_Data\database.config file in plain text:

Code: Select all

<connectionStrings>
  <add name="AbleCommerce" 
    connectionString="Server=dbserver(,port); Database=dbname; Uid=dbuser; Pwd=dbpassword;" 
    providerName="System.Data.SqlClient" />
</connectionStrings>

Re: Connection Strings to databases

Posted: Thu Jul 17, 2008 3:54 pm
by Harley
Thanks i will try that. I am running into an issue with paths to the .mdf file, the xml config files dont like that stuff, even single or double slashing it is not working.

Re: Connection Strings to databases

Posted: Fri Jul 18, 2008 11:48 am
by AbleMods
Harley wrote:Thanks i will try that. I am running into an issue with paths to the .mdf file, the xml config files dont like that stuff, even single or double slashing it is not working.
Are you talking about pointing the database connection string directly to the MDF file? I'm unclear about your mentioning the MDF file paths and xml config files.

Re: Connection Strings to databases

Posted: Sun Jul 20, 2008 11:26 pm
by Harley
I got this to work, i fixed the path stuff. It would be nice do have documentation on what the connection string stuff looks like unencrypted. When you try to change the encryption on your local machine, it errors out on a path variable during the save.

Re: Connection Strings to databases

Posted: Mon Jul 21, 2008 12:56 am
by afm
Harley wrote:It would be nice do have documentation on what the connection string stuff looks like unencrypted.
connectionstrings.com is a pretty good reference.

Re: Connection Strings to databases

Posted: Mon Jul 21, 2008 9:20 am
by Harley
Thanks, I know what they are supposed to look like, what I would like to see is how they look in the app. The one posted above would not have been what i would have guessed. I use the standard ones you see off sites like connectionstring.com. With it encrypted, how would anyone know what its called, stuff like that etc...

Re: Connection Strings to databases

Posted: Mon Jul 21, 2008 9:53 am
by AbleMods
Harley wrote:...With it encrypted, how would anyone know what its called, stuff like that etc...
That's the whole point to encrypting the connection string. It adds another layer of security should the web server itself ever become compromised.

There is no connection string "in the app". Doing so would expose it to others who can access the page source files. There is a configuration page in the Security menu of the admin side that allows you to change the connection string and de-crypt it if necessary. This page is secured by IIS security and only allows site super-user accounts to access it.

Re: Connection Strings to databases

Posted: Mon Jul 21, 2008 10:28 am
by Harley
I realize all that, but as a developer working on this, there are some problems I am encountering. One is that when you go thru the admin pages as you are running this locally, you cant change that encryption thing, it errors out on the save. Since I dont have all the source files, I have to try to figure out what is going on off what I have. Some of this is not that obvious here. I like to be able to go direct on things if I have to.

Re: Connection Strings to databases

Posted: Mon Jul 21, 2008 11:24 am
by afm
I just tried on a local machine and I was able to switch from encrypted to plain text and back using the AC admin page. Sounds like you found a bug. You can report bugs in the CRM.

Re: Connection Strings to databases

Posted: Mon Jul 21, 2008 11:29 am
by jmestep
Here is what an unencrypted connection string looks like in an AC7 site on a shared hoster where it can't be encrypted because of file permissions. It is in the App_Data/database.config file and I think that is where it gets changed if you try from the admin.
<connectionStrings>
<add name="AbleCommerce" connectionString="Server=severname;Database=dbname;Uid=whatever;Pwd=secret;" providerName="System.Data.SqlClient" />
</connectionStrings>