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

G

Guest

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\wwwroot\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
 
G

Guest

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\wwwroot\2\testdisko\access

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

and here's the connstr
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("../acc_dbq/disko.mdb") & ";Mode=ReadWrite|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
 
G

Guest

Mark,

So I created some new libs.

C:\Inetpub\wwwroot\2\testdisko\access is my applib
C:\Inetpub\wwwroot\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
 
D

David Browne

Kenneth P said:
Mark,

So I created some new libs.

C:\Inetpub\wwwroot\2\testdisko\access is my applib
C:\Inetpub\wwwroot\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\wwwroot or d:\websites?

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

David
 
G

Guest

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\wwwroot\ is certainly
not safe.
Now exactly which directory would you expect
Server.MapPath("../") to return? c:\inetpub\wwwroot 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
 
G

Guest

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("ConnString") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("../../../../../../dbq/disko/disko.mdb") &
";Mode=ReadWrite|Share Deny None;Persist Security Info=False"

It works just fine!!!

Why does this NOT work in asp.net?

Kenneth P
 
D

David Browne

Kenneth P said:
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("ConnString") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
_
Server.MapPath("../../../../../../dbq/disko/disko.mdb") &
";Mode=ReadWrite|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.FileInfo(System.IO.Path.Combine(Server.MapPath("/"),
"..\..\..\dbr\db.mdb")).FullName

David
 
G

Guest

David,

Can you explain the word "stuck"? What does it mean?

The word griping I know, I don't think I am.

Anyway, I didn't quite understand what you meant in a former message of this
thread with Systen.IO.Path. Now I know.

Thanks for the code snippet.

Kenneth P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top