我怎样才能连上我得access数据库啊???

panther_totem 2002-03-14 01:04:29
<%
const adopenstatic=3
const adlockpessimistic=2
Set conn=Server.CreateObject("ADODB.Connection")
set rs=server.createobject("adodb.recordset")
DBPath=Server.MapPath("pantherdb.mdb")
conn.Open "drive={Microsoft Access Driver(*.mdb)};dbq="&DBPath
SQLcmd="select * from message order by a_time dese"
re.open sqlcmd,conn,adopenstatic,adlockpessimistic
page=clng(request("txtpage"))
rs.pagesize=10
if page<1 then page=1
if page> rs.pagecount then page=rs.pagecount
rs.absolutepage=page
%>

如上代码,我怎么也连不上我得access数据库,我怎么才能连上?其中pantherdb.mdb和
这个asp页面在同一个目录下。

错误提示如下:
Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005'

[Microsoft][ODBC 驱动程序 管理器] 未发现数据源名称并且未指定默认驱动程序

/show_message.asp,行12

...全文
67 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
panther_totem 2002-03-16
  • 打赏
  • 举报
回复
还有,我在ODBC里配置了,用DSN还是不行,例如:
<%
const adopenstatic=3
const adlockpessimistic=2
Set conn=Server.CreateObject("ADODB.Connection")
set rs=server.createobject("adodb.recordset")
conn.open "DSN=12345"
SQLcmd="select * from message order by a_time desc"
rs.open SQLcmd,conn,adopenstatic,adlockpessimistic
page=clng(request("txtpage"))
rs.pagesize=5
if page<1 then page=1
if page> rs.pagecount then page=rs.pagecount
rs.absolutepage=page
%>
panther_totem 2002-03-16
  • 打赏
  • 举报
回复
我把原来那段代码里的drive该成driver还是真的不行喔。
<%
const adopenstatic=3
const adlockpessimistic=2
Set conn=Server.CreateObject("ADODB.Connection")
set rs=server.createobject("adodb.recordset")
DBPath=Server.MapPath("pantherdb.mdb")
conn.Open "driver={Microsoft Access Driver(*.mdb)};dbq="&DBPath
SQLcmd="select * from message order by a_time dese"
re.open sqlcmd,conn,adopenstatic,adlockpessimistic
page=clng(request("txtpage"))
rs.pagesize=10
if page<1 then page=1
if page> rs.pagecount then page=rs.pagecount
rs.absolutepage=page
%>

panther_totem 2002-03-16
  • 打赏
  • 举报
回复
我改成这样就可以连接上了:
<%
const adopenstatic=3
const adlockpessimistic=2
Set conn=Server.CreateObject("ADODB.Connection")
set rs=server.createobject("adodb.recordset")
DBPath=Server.MapPath("miaoxgdb.mdb")
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&dbpath&";Persist Security Info=False"
SQLcmd="select * from message order by a_time desc"
rs.open SQLcmd,conn,adopenstatic,adlockpessimistic
page=clng(request("txtpage"))
rs.pagesize=5
if page<1 then page=1
if page> rs.pagecount then page=rs.pagecount
rs.absolutepage=page
%>
sportdog 2002-03-16
  • 打赏
  • 举报
回复
用控件生成可行!
netgirl 2002-03-15
  • 打赏
  • 举报
回复
可以用ODBC配置数据库连接,非常简单
在ODBC里配好后,代码只需
set conn=server.createobject("ADODB.Connection")
conn.open "DSN=xxx"

xxx是ODBC里配置的数据库别名
xdaniel 2002-03-15
  • 打赏
  • 举报
回复
是不是access数据库文件的路径有问题啊
julyclyde 2002-03-15
  • 打赏
  • 举报
回复
driver肯定可以
139chen 2002-03-15
  • 打赏
  • 举报
回复
我也遇到相同问题,你连接上后能否把成功的源代码贴一份给我看看。
panther_totem 2002-03-14
  • 打赏
  • 举报
回复
给zhem8(zhem8) 的分先记上,大家再讨论讨论,我一并给分。
panther_totem 2002-03-14
  • 打赏
  • 举报
回复
zhem8(zhem8) 的方法我好像是可以连接上数据库了,不过还有其它的错误,我再自己调试调试。

对了,对于asp连接不同的数据库都有那些格式规范?能不能给分别列举一下??多谢了各位。
panther_totem 2002-03-14
  • 打赏
  • 举报
回复
driver 也不行啊。
julyclyde 2002-03-14
  • 打赏
  • 举报
回复
原来的错误代码中driver写成了drive了
zhem8 2002-03-14
  • 打赏
  • 举报
回复
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Microsoft Visual Studio\VB98\NWIND.MDB;Persist Security Info=False"

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧