Server.MapPath(" ../../ dbq / myDB.mdb")不起作用 [英] Server.MapPath("../../dbq/myDB.mdb") doesn't work

查看:85
本文介绍了Server.MapPath(" ../../ dbq / myDB.mdb")不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个Access数据库并尝试使用

Server.MapPath方法创建一个连接。我在c:\inetprub \ www.root \ apps \ myApp

和c:\inetpub \dbq \ myDB中的数据库中有app lib。


使用Server.MapPath(" ../../../ dbq / myDB"),据我所知,它需要我带来
到myDB lib。但我得到一条错误消息说


不能使用前导..退出顶层目录。


这个在传统的asp工作得非常好。


有什么想法吗?


TIA


Kenneth P

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

推荐答案

" Kenneth P" <柯****** @ discussions.microsoft.com>在消息中写道

新闻:3E ********************************** @ microsof t.com ...
"Kenneth P" <Ke******@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
使用Server.MapPath(" ../../../ dbq / myDB")我应该理解它需要

到myDB lib。但相反,我得到一条错误消息说

不能使用前导..退出顶层目录。
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."




那是的 - ../../../&;您的数据库文件名的一部分正在使IIS

尝试在文​​件系统中的三个目录上运行,从而超过其

虚拟根目录。请参阅以下内容:
http:// www。 4guysfromrolla.com/webtec...tml#postadlink




" Mark Rae" <毫安** @ mark-N-O-S-P-A-M-rae.co.uk>在消息中写道

news:eB ************* @ TK2MSFTNGP15.phx.gbl ...

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eB*************@TK2MSFTNGP15.phx.gbl...
" Kenneth P" <柯****** @ discussions.microsoft.com>在消息中写道
新闻:3E ********************************** @ microsof t.com。 ..
"Kenneth P" <Ke******@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
使用Server.MapPath(" ../../../ dbq / myDB")应该据我所知采取

到myDB lib。但相反,我得到一条错误消息说

不能使用前导..退出顶层目录。
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."



这是对的 - ../../../&;您的数据库文件名的一部分正在制作
IIS尝试在文件系统中上升三个目录,从而超越其虚拟根目录。请参阅以下内容:
http:// www。 4guysfromrolla.com/webtec...tml#postadlink



因此,修复方法是使用Server.MapPath(。)来获取虚拟路径

目录,并使用System.io.Path从那里操纵路径。


David


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


嗨马克,


一些阅读,然后测试几行,没有好结果。


所以我试图建立一个连接到一个访问数据库与app lib处于相同的

级别,但仍然收到此错误消息


这里是我的应用程序库:

C:\ Inetpub \wwwroot \\\\testdisko\access


这里是我的数据库

C:\Inetpub \wwwroot \\\\testdisko \ acc_dbq


这里是'connstr

ConnStr =" Provider = Microso位ft.Jet.OLEDB.4.0;数据源=" &

Server.MapPath(" ../ acc_dbq / disko.mdb")& " ;; Mode = ReadWrite | Share Deny

None; Persist Security Info = False"


如果我放一个物理目录代替这个虚拟

目录


还有什么想法吗?


Kenneth P

" Mark Rae写道:
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
"Mark Rae" wrote:
" Kenneth P" <柯****** @ discussions.microsoft.com>在消息中写道
新闻:3E ********************************** @ microsof t.com。 ..
"Kenneth P" <Ke******@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
使用Server.MapPath(" ../../../ dbq / myDB")应该据我所知采取

到myDB lib。但相反,我得到一条错误消息说

不能使用前导..退出顶层目录。
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."



这是对的 - ../../../&;您的数据库文件名的一部分正在使IIS
尝试在文件系统中的三个目录上运行,从而超越其虚拟根目录。请参阅以下内容:
http:// www。 4guysfromrolla.com/webtec...tml#postadlink



这篇关于Server.MapPath(&quot; ../../ dbq / myDB.mdb&quot;)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆