Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Moving .net site from dev to live server problems with DB connection string mcavill msg:944245 10:04 am on Feb 19, 2005 (gmt 0) I'm fairly new to .net - quite good with classic asp, but trying to build my new sites using .net.
I've got a site running on my PC that writes to a database. The connection string uses the absolute path to the DB (C:\websites\blah\database.mdb) which is fine running on my localserver.
I'm trying to deploy this to my host, so I change the path to the correct path, rebuilt the project - copy the files required to run the project to a new folder and ftp it all to the host.
For some reason the app throws an error telling me the the path is not valid, which is isn't as it's still looking for the C:\websites\blah\database.mdb path.
Why is this? I presumed that if I rebuilt the project it would compile the new path and it would all be good. Any suggestions appreciated :)
mcavill msg:944246 11:09 am on Feb 19, 2005 (gmt 0)
hmmmm - I've got it sorted - my FTP app wasn't overwriting the .dll and .pdb files... martyt msg:944247 5:25 pm on Feb 22, 2005 (gmt 0)
Put the connection string in your web.config - then there's no need to rebuild the app when you want to deploy it. You'll just maintain two different web.config files between the dev and prod environments. mcavill msg:944248 9:18 pm on Feb 22, 2005 (gmt 0)
now that's a great tip - told you I was new to .net - I do that sort of thing with all my classic asp sites, just wasn't sure where to put it in the .net versions :) martyt msg:944249 10:17 pm on Feb 22, 2005 (gmt 0)
You'll add the connection string as an application data key in web config - something like so:
<add key="connectionstring" value="c:\whatever\db1.mdb"/> </appSettings>
Then you'll access it with something like this:
Dim connStr As String
connStr = ConfigurationSettings.AppSettings("connectionstring")
and away you go...