Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: ocean10000

Moving .net site from dev to live server

problems with DB connection string

   
10:04 am on Feb 19, 2005 (gmt 0)

10+ Year Member



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 :)

11:09 am on Feb 19, 2005 (gmt 0)

10+ Year Member



hmmmm - I've got it sorted - my FTP app wasn't overwriting the .dll and .pdb files...
5:25 pm on Feb 22, 2005 (gmt 0)

10+ Year Member



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.
9:18 pm on Feb 22, 2005 (gmt 0)

10+ Year Member



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 :)
10:17 pm on Feb 22, 2005 (gmt 0)

10+ Year Member



You'll add the connection string as an application data key in web config - something like so:

<appSettings>
<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...

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month