经典的asp连接访问数据库,找不到文件

时间:2022-05-21 01:32:50

I am having to work in classic ASP for a small job. I am trying to get the site running on my computer to test. I am running Windows 7 and IIS 7.

我不得不在一个小工作的经典ASP工作。我试图在我的计算机上运行该站点进行测试。我正在运行Windows 7和IIS 7。

I get an error when running from local host and on checking the logs I get the error: 80004005 | Could_not_find_file_'c:\inetpub\wwwroot\sc\website\data\si.mdb'

从本地主机运行时出现错误,检查日志时出现错误:80004005 | Could_not_find_file_'c:\的Inetpub \ wwwroot的\ SC \网站\ DATA \ si.mdb”

My code is like so

我的代码是这样的

dim objConn
dim objRS
set objConn = Server.CreateObject("ADODB.Connection")

objConn.Provider="Microsoft.Jet.OLEDB.4.0"
Set objRS = Server.CreateObject("ADODB.Recordset")

objConn.Open("c:/inetpub/wwwroot/sc/website/data/si.mdb")

This is the exact path to the file however. Anyone know how I can access this? Is the code wrong or are there IIS settings I need to set?

这是文件的确切路径。谁知道我怎么能访问这个?代码是错误还是我需要设置IIS设置?

I do not have any version of Office installed, would that cause a problem?

我没有安装任何版本的Office,会导致问题吗?

I have tried lots of different paths and provider settings but none have worked.

我尝试了很多不同的路径和提供商设置,但没有一个有效。

Edit The code I am working on actually didn't have any connection string details in the code but the person said it still worked on thier computer as a friend setup the test environment.

编辑我正在处理的代码实际上没有代码中的任何连接字符串细节,但该人说它仍然在他们的计算机上作为朋友设置测试环境。

He doesn't recall how his friend setup but said " What I remember from watching him, he connected to the database through Data Sources (ODBC) because as you said in the code theres no direct path as its using a 'global something' (dont know the right term)."

他不记得他的朋友如何设置,但是说“我记得他看过他,他通过数据源(ODBC)连接到数据库,因为正如你在代码中所说的那样,没有直接路径,因为它使用了'全球性的东西'(不知道正确的用语。)“

6 个解决方案

#1


You could try using Process Monitor to see exactly which file is not being found or it is being caused by a permissions issue.

您可以尝试使用进程监视器来确切地查看哪个文件未找到或者是由权限问题引起的。

Also, although using forward slashes instead of backslashes isn't usually a problem, you may want to try changing that in case it makes any difference.

此外,虽然使用正斜杠而不是反斜杠通常不是问题,但您可能需要尝试更改它以防它有任何区别。

If you're using an x64 version of windows, JET is not supported in this mode, though you can get around it by configuring IIS to run x32 applications. To do this, run the following at the command line:

如果您使用的是x64版本的Windows,则此模式不支持JET,但您可以通过配置IIS来运行x32应用程序来解决此问题。为此,请在命令行运行以下命令:

cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 "true"
iisreset

The second command may not be required, but I'm guessing that you would probably need to restart IIS before this change takes effect.

第二个命令可能不是必需的,但我猜你可能需要在此更改生效之前重新启动IIS。

It sounds like the code was previously set to use a global DSN, hence the lack of a path in the connection string, though there should have still been some kind of connection details (like the DSN name).

听起来好像代码以前设置为使用全局DSN,因此连接字符串中缺少路径,尽管应该仍然存在某种连接细节(如DSN名称)。

#2


This may be a permissions issue.

这可能是权限问题。

An easy way to check would be to give full access to everyone for the directory the file is in.

一种简单的检查方法是为文件所在的目录提供完全访问权限。

#3


Maybe you could use the Server.MapPath function as used here http://www.aspwebpro.com/tutorials/asp/dbconnectionopen.asp

也许你可以使用这里使用的Server.MapPath函数http://www.aspwebpro.com/tutorials/asp/dbconnectionopen.asp

#4


Your connection string doesn't look right to me.

您的连接字符串看起来不对我。

See if this helps.

看看这是否有帮助。

EDIT: Do you have JET oledb provider installed?

编辑:您是否安装了JET oledb提供程序?

EDIT2: Check for existence of oledb provider with help from this question.
How to check if an OLEDB driver is installed on the system?

EDIT2:在这个问题的帮助下检查oledb提供者是否存在。如何检查系统上是否安装了OLEDB驱动程序?

#5


I answered a potentially related question the other day. Are you running 64-bit windows 7? If so there is absolutely NO Jet support for x64 OSes. In a real .NET application you could simply recompile the application with x86 as the target. But in your case I am not sure of the solution.

我前几天回答了一个可能相关的问题。你在运行64位Windows 7吗?如果是这样,对于x64操作系统绝对没有Jet支持。在真正的.NET应用程序中,您只需使用x86作为目标重新编译应用程序。但在你的情况下,我不确定解决方案。

Seth

#6


Why does your string say: "c:/inetpub/wwwroot/sc/website/data/si.mdb"

为什么你的字符串说:“c:/inetpub/wwwroot/sc/website/data/si.mdb”

instead of the normal windows path "c:\inetpub\wwwroot\sc\website\data\si.mdb"

而不是正常的Windows路径“c:\ inetpub \ wwwroot \ sc \ website \ data \ si.mdb”

Also, you could go to Control Panel->Administrative Tools->Data Source (ODBC) and create a new named DSN under the System tab. Name it si for example and make sure the type is access, give it the right path to the access db and then your code would just be:

此外,您可以转到“控制面板” - >“管理工具” - >“数据源”(ODBC),并在“系统”选项卡下创建一个新的命名DSN。例如,将其命名为si并确保类型为access,为其提供访问db的正确路径,然后您的代码将是:

dim objConn
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open("si")

#1


You could try using Process Monitor to see exactly which file is not being found or it is being caused by a permissions issue.

您可以尝试使用进程监视器来确切地查看哪个文件未找到或者是由权限问题引起的。

Also, although using forward slashes instead of backslashes isn't usually a problem, you may want to try changing that in case it makes any difference.

此外,虽然使用正斜杠而不是反斜杠通常不是问题,但您可能需要尝试更改它以防它有任何区别。

If you're using an x64 version of windows, JET is not supported in this mode, though you can get around it by configuring IIS to run x32 applications. To do this, run the following at the command line:

如果您使用的是x64版本的Windows,则此模式不支持JET,但您可以通过配置IIS来运行x32应用程序来解决此问题。为此,请在命令行运行以下命令:

cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 "true"
iisreset

The second command may not be required, but I'm guessing that you would probably need to restart IIS before this change takes effect.

第二个命令可能不是必需的,但我猜你可能需要在此更改生效之前重新启动IIS。

It sounds like the code was previously set to use a global DSN, hence the lack of a path in the connection string, though there should have still been some kind of connection details (like the DSN name).

听起来好像代码以前设置为使用全局DSN,因此连接字符串中缺少路径,尽管应该仍然存在某种连接细节(如DSN名称)。

#2


This may be a permissions issue.

这可能是权限问题。

An easy way to check would be to give full access to everyone for the directory the file is in.

一种简单的检查方法是为文件所在的目录提供完全访问权限。

#3


Maybe you could use the Server.MapPath function as used here http://www.aspwebpro.com/tutorials/asp/dbconnectionopen.asp

也许你可以使用这里使用的Server.MapPath函数http://www.aspwebpro.com/tutorials/asp/dbconnectionopen.asp

#4


Your connection string doesn't look right to me.

您的连接字符串看起来不对我。

See if this helps.

看看这是否有帮助。

EDIT: Do you have JET oledb provider installed?

编辑:您是否安装了JET oledb提供程序?

EDIT2: Check for existence of oledb provider with help from this question.
How to check if an OLEDB driver is installed on the system?

EDIT2:在这个问题的帮助下检查oledb提供者是否存在。如何检查系统上是否安装了OLEDB驱动程序?

#5


I answered a potentially related question the other day. Are you running 64-bit windows 7? If so there is absolutely NO Jet support for x64 OSes. In a real .NET application you could simply recompile the application with x86 as the target. But in your case I am not sure of the solution.

我前几天回答了一个可能相关的问题。你在运行64位Windows 7吗?如果是这样,对于x64操作系统绝对没有Jet支持。在真正的.NET应用程序中,您只需使用x86作为目标重新编译应用程序。但在你的情况下,我不确定解决方案。

Seth

#6


Why does your string say: "c:/inetpub/wwwroot/sc/website/data/si.mdb"

为什么你的字符串说:“c:/inetpub/wwwroot/sc/website/data/si.mdb”

instead of the normal windows path "c:\inetpub\wwwroot\sc\website\data\si.mdb"

而不是正常的Windows路径“c:\ inetpub \ wwwroot \ sc \ website \ data \ si.mdb”

Also, you could go to Control Panel->Administrative Tools->Data Source (ODBC) and create a new named DSN under the System tab. Name it si for example and make sure the type is access, give it the right path to the access db and then your code would just be:

此外,您可以转到“控制面板” - >“管理工具” - >“数据源”(ODBC),并在“系统”选项卡下创建一个新的命名DSN。例如,将其命名为si并确保类型为access,为其提供访问db的正确路径,然后您的代码将是:

dim objConn
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open("si")