Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
Moving .net site from dev to live server problems with DB connection string mcavill
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 :)
hmmmm - I've got it sorted - my FTP app wasn't overwriting the .dll and .pdb files... martyt
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
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
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...