 |
 |

02-24-2007, 03:04 AM
|
 |
Senior Contributor
|
|
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
|
|
Server.MapPath in Web.Config
|
Ok, here it is.
I put this:
Quote:
<appSettings>
<add key="SqlConnStrO" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents and Settings/Desktop/dbJoyMarble.mdb;Persist Security Info=False;"/>
</appSettings>
|
in the Web.Config. But when I try to use Server.MapPath, it gives back an error! Server --- not defined.
What gives?
|
__________________
Pinoy ako.. ipinagmamalaki ko.
|

02-24-2007, 03:22 AM
|
 |
Senior Contributor
|
|
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
|
|
|
also.. I am calling the appsetting in my DAL, in the class, and Server.MapPath also does not function there.
|
__________________
Pinoy ako.. ipinagmamalaki ko.
|

02-24-2007, 04:58 AM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
Is this a webforms application? If it is, then you don't need Server.MapPath to find the web.config. If it isn't, then duh.
|
__________________
~ Quod non mortiferum, fortiorem me facit ~
Avatar by lebb
|

02-25-2007, 03:38 PM
|
 |
Senior Contributor
|
|
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
|
|
|
yes this is a webform, that's why I have a web.config
I'm not using server.mappath to find web.config, I'm trying to change the connection string. The static connection string "C:/.../mytable.mdb" won't work because the table is now located in the webhost and I can't seem to use the url "www.sitename.com/tables/mytable.mdb" as part of the connection string.
|
__________________
Pinoy ako.. ipinagmamalaki ko.
|

02-27-2007, 07:09 PM
|
|
Ultimate Contributor
Retired Leader * Expert *
|
|
Join Date: Jul 2003
Location: Camp Hill, PA
Posts: 1,992
|
|
|
Most hosting providers will give you either the physical path of your site or an ODBC DSN to use. Do you have anything from them regarding the physical location of your files?
|
|

02-27-2007, 07:20 PM
|
 |
Senior Contributor
|
|
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
|
|
|
just the URL.
I have resolved this issue (a bit) by placing the Server.MapPath call within the pages and the Driver, password, and other connection string information in Web.Config.
|
__________________
Pinoy ako.. ipinagmamalaki ko.
|

02-27-2007, 07:33 PM
|
|
Ultimate Contributor
Retired Leader * Expert *
|
|
Join Date: Jul 2003
Location: Camp Hill, PA
Posts: 1,992
|
|
Quote:
|
I have resolved this issue (a bit) by placing the Server.MapPath call within the pages...
|
That was going to be my next suggestion with the caveat that you should check to ensure you site is not being hosted in a web farm/garden (which would obviously cause serious problems with any file references).
|
|

02-28-2007, 08:58 AM
|
 |
Web Junkie
Retired Moderator * Expert *
|
|
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
|
|
The whole point of a .config file is that it probably changes from machine to machine. I have a hardcoded path in my web.config on my test machine. I have a different hardcoded path in my web.config on my production machine. When I move files to production, I just don't change the config.
Using .NET 2.0, Microsoft has a Tool (Web Deployment Projects) that makes the process a little easier. See Scott Guthrie's blog here: http://weblogs.asp.net/scottgu/archi...06/429723.aspx
|
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|