473,735 Members | 5,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.MapPath( "../../dbq/myDB.mdb") doesn't work

Hi all,

I have an Access database and try to create a connection to it using the
Server.MapPath method. I have the app lib in c:\inetprub\www root\apps\myApp
and the database in c:\inetpub\dbq\ myDB.

Using Server.MapPath( "../../../dbq/myDB") should as I understand it take me
to the myDB lib. But instead I get an error message saying

"Cannot use a leading .. to exit above the top directory."

This worked very good in traditional asp.

Any ideas?

TIA

Kenneth P

Nov 18 '05 #1
10 9038
"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
Using Server.MapPath( "../../../dbq/myDB") should as I understand it take
me
to the myDB lib. But instead I get an error message saying

"Cannot use a leading .. to exit above the top directory."


That's right - the "../../../" part of your database filename is making IIS
try to go up three directories in the file system, thereby going past its
virtual root. See the following:
http://www.4guysfromrolla.com/webtec...tml#postadlink
Nov 18 '05 #2

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eB******** *****@TK2MSFTNG P15.phx.gbl...
"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
Using Server.MapPath( "../../../dbq/myDB") should as I understand it take
me
to the myDB lib. But instead I get an error message saying

"Cannot use a leading .. to exit above the top directory."


That's right - the "../../../" part of your database filename is making
IIS try to go up three directories in the file system, thereby going past
its virtual root. See the following:
http://www.4guysfromrolla.com/webtec...tml#postadlink

So the fix is to use Server.MapPath( ".") to get the path of the virtual
directory, and use System.io.Path manipulate the path from there.

David
Nov 18 '05 #3
Hi Mark,

Some reading, then testing a few lines, no good result.

So I tried to create a connection to an access database that is on the same
level as the app lib but still I get this error message

Here's my app lib:
C:\Inetpub\wwwr oot\2\testdisko \access

and here's my data lib
C:\Inetpub\wwwr oot\2\testdisko \acc_dbq

and here's the connstr
ConnStr = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "../acc_dbq/disko.mdb") & ";Mode=ReadWrit e|Share Deny
None;Persist Security Info=False"

It works just fine if I put a physical directory instead of this virtual
directory

Any further ideas?

Kenneth P
"Mark Rae" wrote:
"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
Using Server.MapPath( "../../../dbq/myDB") should as I understand it take
me
to the myDB lib. But instead I get an error message saying

"Cannot use a leading .. to exit above the top directory."


That's right - the "../../../" part of your database filename is making IIS
try to go up three directories in the file system, thereby going past its
virtual root. See the following:
http://www.4guysfromrolla.com/webtec...tml#postadlink

Nov 18 '05 #4
Mark,

So I created some new libs.

C:\Inetpub\wwwr oot\2\testdisko \access is my applib
C:\Inetpub\wwwr oot\2\testdisko \acc_dbq is my dbqlib

with Sever.MapPath(" ../acc_dbq/disko.mdb") NOT WORKING

which loud and clear says Microsoft is not allowing us to go up even one
level to solve this issue. Why? Strategic rules? Of course no problems with
sqlserver and probably not even with mySql server (although I have not tried
it yet)

I program in asp.net with code behind and I offen use different app libs to
more easy admin the project, avoiding having all .aspx in the same lib, thus
giving you better control of the application.

Suppose I'd like to create a project as follows:

Applib1
Applib2
Applib3

and in the root lib in my project I have a login.aspx

I want to use Access 2000 or newer as the database.

Where shall I put the dbq lib?

I can't create a Dbqlib and access from Applib2 because Microsoft can't
allow it

"Cannot use a leading .. to exit above the top directory."

This means I have to create a Dbqlib under every Applib with many databases
with a lot of redundancy and lots of extra programming and keeping up all
dbq:s

Is this really what Microsoft expect us to do when dealing with Access?
Probably since they want us to use MSDE instead.

I have my apps on a web hotel where you can have Access databases, even
Visual Foxpro databases which are extremely fast compered to access and even
MSDE, but they have their rules with sqlserver databases and they wan't let
me in with MSDE databases although EULA says it's OK to do so.

Most swedish web hotels want considerably fees for setting upp sqlserver2000
databases for you, and today I can't afford these costs.

Kenneth P
"Mark Rae" wrote:
"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
Using Server.MapPath( "../../../dbq/myDB") should as I understand it take
me
to the myDB lib. But instead I get an error message saying

"Cannot use a leading .. to exit above the top directory."


That's right - the "../../../" part of your database filename is making IIS
try to go up three directories in the file system, thereby going past its
virtual root. See the following:
http://www.4guysfromrolla.com/webtec...tml#postadlink

Nov 18 '05 #5

"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:54******** *************** ***********@mic rosoft.com...
Mark,

So I created some new libs.

C:\Inetpub\wwwr oot\2\testdisko \access is my applib
C:\Inetpub\wwwr oot\2\testdisko \acc_dbq is my dbqlib

with Sever.MapPath(" ../acc_dbq/disko.mdb") NOT WORKING


It's not supposed to work. A virtual directory often _not_ under
inetpub\wwwroot . You might have the virtual directories all under
d:\websites. Now exactly which directory would you expect
Server.MapPath( "../") to return? c:\inetpub\wwwr oot or d:\websites?

Again, just use Server.MapPath to find the physical path of your virtual
root, and handle it yourself from there.

David
Nov 18 '05 #6
Hi David,

I'm thinking security for the most. In a web hotel the customer is not a guy
with admin rights, he has to rely on their admin. What if the hotel doesn't
have a ddrive? To place a db somewhere below c:\inetpub\wwwr oot\ is certainly
not safe.
Now exactly which directory would you expect
Server.MapPath ("../") to return? c:\inetpub\wwwr oot or d:\websites?
None of them. I'd like for security reasons the Server.MapPath( "../...) to
point to c:\inetpub\dbq. Then I know the db is much more secure from hackers
to steal my db.

I know I can write a physical adress (c:\inetpub\dbq \myDb) instead of a
virtual address with Server.MapPath, but I want things to go smooth without
taking contact to the admin on the webhotel every time I want to insert a new
db on their server. This will most often cost per time you ask them.

Is there a way in .net to write code that a nonadmin can hide or make
readonly on certain libs?

Kenneth P

"David Browne" wrote:

"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:54******** *************** ***********@mic rosoft.com...
Mark,

So I created some new libs.

C:\Inetpub\wwwr oot\2\testdisko \access is my applib
C:\Inetpub\wwwr oot\2\testdisko \acc_dbq is my dbqlib

with Sever.MapPath(" ../acc_dbq/disko.mdb") NOT WORKING


It's not supposed to work. A virtual directory often _not_ under
inetpub\wwwroot . You might have the virtual directories all under
d:\websites. Now exactly which directory would you expect
Server.MapPath( "../") to return? c:\inetpub\wwwr oot or d:\websites?

Again, just use Server.MapPath to find the physical path of your virtual
root, and handle it yourself from there.

David

Nov 18 '05 #7
Hi David,

It's not supposed to work?

I have an traditional asp app named Disko. In IIS I set up a virtual lib
called asp_disko that pointed to the actual lib. In the URL I wrote
http://localhost/asp_disko/login.asp and the app started. Entered username
and password. Klicked Submit button. In the control.asp file I have

Session("ConnSt ring") = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
Server.MapPath( "../../../../../../dbq/disko/disko.mdb") &
";Mode=ReadWrit e|Share Deny None;Persist Security Info=False"

It works just fine!!!

Why does this NOT work in asp.net?

Kenneth P
"David Browne" wrote:

"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:54******** *************** ***********@mic rosoft.com...
Mark,

So I created some new libs.

C:\Inetpub\wwwr oot\2\testdisko \access is my applib
C:\Inetpub\wwwr oot\2\testdisko \acc_dbq is my dbqlib

with Sever.MapPath(" ../acc_dbq/disko.mdb") NOT WORKING


It's not supposed to work. A virtual directory often _not_ under
inetpub\wwwroot . You might have the virtual directories all under
d:\websites. Now exactly which directory would you expect
Server.MapPath( "../") to return? c:\inetpub\wwwr oot or d:\websites?

Again, just use Server.MapPath to find the physical path of your virtual
root, and handle it yourself from there.

David

Nov 18 '05 #8

"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:63******** *************** ***********@mic rosoft.com...
Hi David,

It's not supposed to work?

I have an traditional asp app named Disko. In IIS I set up a virtual lib
called asp_disko that pointed to the actual lib. In the URL I wrote
http://localhost/asp_disko/login.asp and the app started. Entered username
and password. Klicked Submit button. In the control.asp file I have

Session("ConnSt ring") = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
_
Server.MapPath( "../../../../../../dbq/disko/disko.mdb") &
";Mode=ReadWrit e|Share Deny None;Persist Security Info=False"

It works just fine!!!

Why does this NOT work in asp.net?


Are you really stuck, or are you just griping?

This is not a showstopper issue. Just do something like this:
Dim dbFileName As String = New
System.IO.FileI nfo(System.IO.P ath.Combine(Ser ver.MapPath("/"),
"..\..\..\dbr\d b.mdb")).FullNa me

David
Nov 18 '05 #9
"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> wrote in
message news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Are you really stuck, or are you just griping?


How many times does one person need one question answered...? :-)
Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6208
by: Mikkky | last post by:
The sample code below returns and error " The type or namspace name 'Server' could not be found". Please help. using System;using System.IO; using System.Xml;using System.Diagnostics; using System.Collections;using System.Web;using System.Web.UI; using System.Web.UI.WebControls;using System.Web.UI.HtmlControls; public class Business { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("Rules.xml"));
4
9414
by: ramonred | last post by:
txtUpload1.PostedFile.SaveAs(Server.MapPath("~") + "\\" + file1.Name); this code loads the file in the root directory of my application, by using the tilde. How do I accomplish getting the file to loaded above root. My application is within another applilcation (subdomain). I guess I am looking the .net equivalent to .. in unix. Thanks.
2
8402
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
1
1822
by: Jim Heavey | last post by:
Hello, I am trying out how to programatically figure out where my datafile is. I thought I could use Server.MapPath to provide me the name of where my webpage is located, as I have used that in other situations, but this situation is different. My web pages and data file do not reside on the same drive as where the server resides, so Sever.MapPath is propbably not the right method. How do I find the path where my actual web page is...
2
3799
by: Tee | last post by:
Hi, I am currently using Server.MapPath in my aspx files, but because of I am using it more than once, I would like to move these code away from aspx and make it as a public function inside Module, but I am having problem with it. As "Server.MapPath" is not allow in other .vb file ... can anyone help with this ? or if we really can't make it, is there any other way could do it ? Thanks,
2
2911
by: lucy | last post by:
Hi, I use ADOX to create a Access database programmatically from my asp.net application and save ".mdb" file to a temp folder under my project foler on the web server. After database is created successfuly, I saw two files ".mdb" and ".ldb" in my temp folder. I have no problem to open the database manually. But when I'm tring to use Response.WriteFile() to download database file to end user's local machine, I kept getting the following
1
3098
by: Denton | last post by:
Hi all: I working in MS window environment. Now I want to use a python script to import some data from CSV file to MDB file. but I have some problems about creating MDB file in DAO. I am using attached code , but the last line seems invalid. Does anyone could help me. Thanks! import win32com.client eng=win32com.client.Dispatch("DAO.DBEngine.36")
5
9625
by: MichiMichi | last post by:
When using Server.MapPath on IIS 5 on my localhost everything works well. All of the following commands are executed without any error Response.Write(Server.MapPath("/app_test") & "<br>") Response.Write(Server.MapPath("app_test") & "<br>") Response.Write(Server.MapPath("~") & "<br>") However, running the first statement on via the internal Visual Studio 2005 Server I receive an error for
6
13688
by: Patrick.Simons | last post by:
I try to connect a FTPWebRequest through Proxy and VPN to a remote FTP- server. Sometimes it works sometimes not. When my VB.Net-App (2005) returns the error on the GetResponse-Method, I'll try to use the Windows Explorer to go on the FTP-URI and this always works. So the problem should come from my app. my simplified code: Private m_oFTP As FtpWebRequest Private oResponseDir As FtpWebResponse = Nothing
0
8959
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8784
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9462
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9199
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6747
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4821
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2187
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.