在ASP文件中创建记录集对象时出现错误80004005,但在Global.ASA中正常工作 [英] Error 80004005 when creating recordset object in ASP file, but works fine in Global.ASA
问题描述
出于某种原因,我在尝试从我的INDEX.ASP页面上的Win2K3机器上的
Access数据库上打开记录集时遇到错误,但是相同的
$ b $来自GLOBAL.ASA页面时,b代码可以很好地访问数据库。我是
使用DSN连接到数据库。
我得到的错误是:
用于ODBC驱动程序的Microsoft OLE DB提供程序错误''80004005''
[Microsoft] [ODBC驱动程序管理器]找不到数据源名称且没有
指定默认驱动程序
/index.asp,行14
我的代码如下:
dim objConn
set objConn = server.CreateObject(" ADODB.Connection")
objConn.Open" DNS = SparesDB.dsn"
dim objRS
set objRS = server.CreateObject(" ADODB.Recordset")
objRS.Open" SELECT * FROM tblUsers WHERE UserName =''" &
request.form(" txtuser")& "''AND Password =''" &安培; request.form(" txtPass")&
"'';",objConn ,, 3
if objRS.recordcount = 1 then
...一些代码
错误发生在''set objRS = server.CreateObject(" ADODB.Recordset")''
>
DSN没有用户名/密码。我同时禁用并启用匿名访问该网站的
匿名访问。禁用访问会强制我在执行GLOBAL.ASA时输入
有效域用户名/密码组合,但
我的INDEX.ASP页面中仍然出现相同的错误。
我的文件位置如下:
- D:\ Interter \ mypage.com \web保存我的网页(ASP,HTML, CSS,图片,
等)
- D:\ Interter \ mypage.com \ db保存我的MS Access数据库(我最终会
将数据库迁移到正确的MS SQL服务器)
- 我的DSN名为SparesDB.dsn,没有密码并指向我的访问
文件。
由于我的DB文件夹与我的WEB文件夹处于同一级别,因此我不需要
来指定用户名或密码。至少这是我在网上找到的:
"使用DSN和用户ID /密码(注意:如果您放置数据库
,则不需要用户/通行证在/ database目录中与公众相同的级别
/ htm l目录,所以很少使用)是否有必要在文件夹html中命名
。和数据库 ???
感谢任何帮助!!!
For some reason I am getting an error when trying to open a recordset on an
Access database on my Win2K3 machine from my INDEX.ASP page, but the same
code accesses the database fine when coming from the GLOBAL.ASA page. I''m
using a DSN to connect to the database.
The error I''m getting is:
Microsoft OLE DB Provider for ODBC Drivers error ''80004005''
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/index.asp, line 14
My code looks like:
dim objConn
set objConn= server.CreateObject("ADODB.Connection")
objConn.Open "DNS=SparesDB.dsn"
dim objRS
set objRS = server.CreateObject("ADODB.Recordset")
objRS.Open "SELECT * FROM tblUsers WHERE UserName=''" &
request.form("txtuser") & "'' AND Password=''" & request.form("txtPass") &
"'';", objConn, ,3
if objRS.recordcount=1 then
...some code
The error occurs in ''set objRS = server.CreateObject("ADODB.Recordset")''
The DSN has no username/password. I have both disabling and enabling
anonymous access to the web site. Disabling access forces me to enter a
valid domain username/password combination when GLOBAL.ASA is executed, but
I still get the same error in my INDEX.ASP page.
My files are located as follows:
- D:\Internet\mypage.com\web holds my web pages (ASP, HTML, CSS, images,
etc.)
- D:\Internet\mypage.com\db holds my MS Access database (I will eventually
migrate the database to a proper MS SQL server)
- My DSN is named "SparesDB.dsn", has no password and points to my Access
file.
Since my DB folder is at the same level as my WEB folder, I shouldn''t need
to specify a username or password... At least this is what I found online:
"With DSN and User ID/Password (NOTE: a user/pass is NOT needed if you place
your database in the /database directory on the same level as the public
/html directory so this is rarely used)" Is it necessary to actually name
the folders "html" and "database" ???
Any assistance is appreciated!!!
推荐答案
问题是这一行:
objConn.Open" DNS = SparesDB.dsn"
相反,请使用:
objConn.OpenDSN = SparesDB
(注意DSN是拼写错误,如果你有一个系统,你不需要扩展名
DSN ,因为信息存储在注册表中。
那说你应该使用Jet OLEDB Provider。
干杯
Ken
" Grahammer" < PO ******** @ 127.0.0.1>在消息中写道
新闻:ef ************** @ TK2MSFTNGP12.phx.gbl ...
:出于某种原因我尝试打开记录集时出现错误
和
:从我的INDEX.ASP页面访问我的Win2K3机器上的数据库,但是相同的
:来自GLOBAL.ASA页面时,代码可以很好地访问数据库。我是
:使用DSN连接数据库。
:
:我得到的错误是:
:用于ODBC驱动程序的Microsoft OLE DB提供程序错误''80004005''
:指定默认驱动程序
:/index.asp,第14行
:
:我的代码如下:
:dim objConn
:set objConn = server.CreateObject(" ADODB.Connection")
:objConn.Open" DNS = SparesDB.dsn"
:dim objRS
:set objRS = server.CreateObject(" ADODB.Recordset")
:objRS.Open" SELECT * FROM tblUsers WHERE UserName =''" &
:request.form(" txtuser")& "''AND Password =''" &安培; request.form(" txtPass")&
:"'';",objConn ,, 3
:if objRS.recordcount = 1 then
:...一些代码
:
:错误发生在''set objRS = server.CreateObject(" ADODB.Recordset") ''
:
:DSN没有用户名/密码。我同时禁用和启用
:匿名访问网站。禁用访问权限迫使我输入
:执行GLOBAL.ASA时的有效域用户名/密码组合,
但是
:我仍然得到我的INDEX.ASP页面中的错误相同。
:
:我的文件位置如下:
: - D:\Internet \ mypage.com \web拥有我的网页(ASP,HTML,CSS,图片,
:等等)
: - D:\Internet \ mypage.com \ db拥有我的MS Access数据库(我将最终确定
:将数据库迁移到合适的MS SQL服务器)
: - 我的DSN名为SparesDB.dsn,没有密码并指向我的访问
:文件。
:
:由于我的DB文件夹与我的WEB文件夹处于同一级别,我不需要
:指定用户名或密码...至少这是我在网上找到的:
:使用DSN和用户ID /密码(注意:如果您需要用户/通行证
地点
:您的数据库在/ database目录中与公共
:/ html目录处于同一级别,因此很少使用)是否有必要实际命名
:文件夹html和数据库 ???
:
:任何帮助表示赞赏!!!
:
:
The problem is this line:
objConn.Open "DNS=SparesDB.dsn"
Instead, use:
objConn.Open "DSN=SparesDB"
(note DSN is misspelt, and you don''t need the extension if you have a system
DSN, since the information is stored in the registry).
That said you should probably use the Jet OLEDB Provider instead.
Cheers
Ken
"Grahammer" <po********@127.0.0.1> wrote in message
news:ef**************@TK2MSFTNGP12.phx.gbl...
: For some reason I am getting an error when trying to open a recordset on
an
: Access database on my Win2K3 machine from my INDEX.ASP page, but the same
: code accesses the database fine when coming from the GLOBAL.ASA page. I''m
: using a DSN to connect to the database.
:
: The error I''m getting is:
: Microsoft OLE DB Provider for ODBC Drivers error ''80004005''
: [Microsoft][ODBC Driver Manager] Data source name not found and no
: default driver specified
: /index.asp, line 14
:
: My code looks like:
: dim objConn
: set objConn= server.CreateObject("ADODB.Connection")
: objConn.Open "DNS=SparesDB.dsn"
: dim objRS
: set objRS = server.CreateObject("ADODB.Recordset")
: objRS.Open "SELECT * FROM tblUsers WHERE UserName=''" &
: request.form("txtuser") & "'' AND Password=''" & request.form("txtPass") &
: "'';", objConn, ,3
: if objRS.recordcount=1 then
: ...some code
:
: The error occurs in ''set objRS = server.CreateObject("ADODB.Recordset")''
:
: The DSN has no username/password. I have both disabling and enabling
: anonymous access to the web site. Disabling access forces me to enter a
: valid domain username/password combination when GLOBAL.ASA is executed,
but
: I still get the same error in my INDEX.ASP page.
:
: My files are located as follows:
: - D:\Internet\mypage.com\web holds my web pages (ASP, HTML, CSS, images,
: etc.)
: - D:\Internet\mypage.com\db holds my MS Access database (I will
eventually
: migrate the database to a proper MS SQL server)
: - My DSN is named "SparesDB.dsn", has no password and points to my Access
: file.
:
: Since my DB folder is at the same level as my WEB folder, I shouldn''t need
: to specify a username or password... At least this is what I found online:
: "With DSN and User ID/Password (NOTE: a user/pass is NOT needed if you
place
: your database in the /database directory on the same level as the public
: /html directory so this is rarely used)" Is it necessary to actually name
: the folders "html" and "database" ???
:
: Any assistance is appreciated!!!
:
:
我觉得自己像个白痴!
我盯着那个小时候玩的东西!
我非常感激!
BTW ......我对此很新。使用Jet OLEDB
提供商涉及什么?
谢谢!
" Ken Schaefer" <柯******* @ THISadOpenStatic.com>在留言中写道
新闻:uG ************** @ TK2MSFTNGP10.phx.gbl ...
Do I feel like an idiot!
I stared at that thing for an HOUR!
I appreciate it muchly!
BTW... I''m quite new to this. What is involved in using the Jet OLEDB
provider?
Thanks!
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:uG**************@TK2MSFTNGP10.phx.gbl...
问题是这一行:
objConn.Open" DNS = SparesDB.dsn"
而是使用:
objConn.OpenDSN = SparesDB
(注意DSN是拼写错误,如果您有
a系统DSN,则不需要扩展名,因为信息存储在注册表中)。
那说你应该使用Jet OLEDB Provider。
Grahammer < PO ******** @ 127.0.0.1>在消息中写道
新闻:ef ************** @ TK2MSFTNGP12.phx.gbl ...
:出于某种原因,我在尝试打开时收到错误从我的INDEX.ASP页面上我的Win2K3机器上的
:Access数据库上的
记录集,但
相同:代码从GLOBAL.ASA
获得数据库正常页。我是:使用DSN连接到数据库。
:
:我得到的错误是:
:Microsoft OLE DB Provider for ODBC Drivers错误''80004005' '
:[Microsoft] [ODBC驱动程序管理器]未找到数据源名称和
否:指定默认驱动程序
:/ index.asp,第14行
The problem is this line:
objConn.Open "DNS=SparesDB.dsn"
Instead, use:
objConn.Open "DSN=SparesDB"
(note DSN is misspelt, and you don''t need the extension if you have a system DSN, since the information is stored in the registry).
That said you should probably use the Jet OLEDB Provider instead. "Grahammer" <po********@127.0.0.1> wrote in message
news:ef**************@TK2MSFTNGP12.phx.gbl...
: For some reason I am getting an error when trying to open a recordset on an
: Access database on my Win2K3 machine from my INDEX.ASP page, but the same : code accesses the database fine when coming from the GLOBAL.ASA page. I''m : using a DSN to connect to the database.
:
: The error I''m getting is:
: Microsoft OLE DB Provider for ODBC Drivers error ''80004005''
: [Microsoft][ODBC Driver Manager] Data source name not found and no : default driver specified
: /index.asp, line 14
strConnect = _
" Provider = Microsoft.Jet.OLEDB.4.0;" &安培; _
"数据源= c:\database \ myDatabase.mdb;"
如果您不知道物理路径您的数据库,您可以使用
Server.Mappath()函数返回物理路径。
最新的Jet Provider可在此处获取:
http://support.microsoft.com/default...;en-us;282010&
干杯
Ken
" Grahammer" <我们******* @ 127.0.0.1>在消息中写道
news:e%**************** @ TK2MSFTNGP12.phx.gbl ...
:Do我觉得自己像个白痴!
:
:我盯着那个小东西!
:
:我非常感激!
:
:BTW ......我对此很新。使用Jet OLEDB涉及什么
:提供商?
:
:谢谢!
:
:
:Ken Schaefer <柯******* @ THISadOpenStatic.com>在消息中写道
:news:uG ************** @ TK2MSFTNGP10.phx.gbl ...
:>问题是这一行:
:>
:> objConn.Open" DNS = SparesDB.dsn"
:>
:>相反,使用:
:>
:> objConn.OpenDSN = SparesDB
:>
:> (注意DSN是拼写错误的,如果你有
,你不需要扩展名:系统
:> DSN,因为信息存储在注册表中)。
:>
:>那说你应该使用Jet OLEDB Provider。
:
:> " Grahammer" < PO ******** @ 127.0.0.1>在消息中写道
:>新闻:ef ************** @ TK2MSFTNGP12.phx.gbl ...
:> :由于某些原因,我在尝试打开
时记录集时出现错误:b $ b:>
:> :从我的INDEX.ASP页面访问我的Win2K3机器上的数据库,但
:相同的
:> :代码从GLOBAL.ASA
:页面访问数据库时很好。我是
:> :使用DSN连接数据库。
:> :
:> :我得到的错误是:
:> :Microsoft OLE DB Provider for ODBC Drivers错误''80004005''
:> :[Microsoft] [ODBC驱动程序管理器]找不到数据源名称和
:否
:> :指定默认驱动程序
:> :/index.asp,第14行
:
:
strConnect = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\database\myDatabase.mdb;"
If you don''t know the physical path to your database, you can use the
Server.Mappath() function to return the physical path.
The latest Jet Provider is available here:
http://support.microsoft.com/default...;en-us;282010&
Cheers
Ken
"Grahammer" <we*******@127.0.0.1> wrote in message
news:e%****************@TK2MSFTNGP12.phx.gbl...
: Do I feel like an idiot!
:
: I stared at that thing for an HOUR!
:
: I appreciate it muchly!
:
: BTW... I''m quite new to this. What is involved in using the Jet OLEDB
: provider?
:
: Thanks!
:
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:uG**************@TK2MSFTNGP10.phx.gbl...
: > The problem is this line:
: >
: > objConn.Open "DNS=SparesDB.dsn"
: >
: > Instead, use:
: >
: > objConn.Open "DSN=SparesDB"
: >
: > (note DSN is misspelt, and you don''t need the extension if you have
: a system
: > DSN, since the information is stored in the registry).
: >
: > That said you should probably use the Jet OLEDB Provider instead.
:
: > "Grahammer" <po********@127.0.0.1> wrote in message
: > news:ef**************@TK2MSFTNGP12.phx.gbl...
: > : For some reason I am getting an error when trying to open a
: recordset on
: > an
: > : Access database on my Win2K3 machine from my INDEX.ASP page, but
: the same
: > : code accesses the database fine when coming from the GLOBAL.ASA
: page. I''m
: > : using a DSN to connect to the database.
: > :
: > : The error I''m getting is:
: > : Microsoft OLE DB Provider for ODBC Drivers error ''80004005''
: > : [Microsoft][ODBC Driver Manager] Data source name not found and
: no
: > : default driver specified
: > : /index.asp, line 14
:
:
这篇关于在ASP文件中创建记录集对象时出现错误80004005,但在Global.ASA中正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!