关于ASP读取数据库
来源:百度知道 编辑:UC知道 时间:2024/05/22 12:34:27
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
dim connstr
connstr="provider=microsoft.jet.oledb.4.0:data source=" & server.MapPath("chezhushuju.mdb")
set bb = server.CreateObject("adodb.connection")
bb.open connstr
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>读取信息</title>
</head>
<%
set rs =server.CreateObject("sdobd.recordset")
rs.open"sel
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
dim connstr
connstr="provider=microsoft.jet.oledb.4.0:data source=" & server.MapPath("chezhushuju.mdb")
set bb = server.CreateObject("adodb.connection")
bb.open connstr
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>读取信息</title>
</head>
<%
set rs =server.CreateObject("sdobd.recordset")
rs.open"sel
应该是:
rs.open"select * form e:\chezhu\chezhushuju ",bb,1,1
Select 查询字段 from 表名[ Where 查询条件语句 [排序语句或分组语句]]
e:\chezhu\chezhushuju 应该改为一张表名
对于你补充:
一、
原来上面还有一处错误,
set rs =server.CreateObject("sdobd.recordset") 是什么?
应该改为
set rs=server.CreateObject("adodb.recordset")
rs.open "select * form 数据库中的一张表名",bb,1,1
二、
这与虚拟机没关系吧,但也要注意两点:
1.保证你的数据库文件与asp在同一个文件下。
2.你的IIS及asp文件是在物理主机里的就在物理主机上访问,在虚拟机下的就在虚拟机访问。
对回答的内容有问题,或认为不妥,百度消息我。
我认为:百度消息就是很好的联系方式
(在消息的内容里加上问题的网址哦)
rs.open"select * form e:\chezhu\chezhushuju ",bb,1,1
这条语句错了!
rs.open "select * form 表名",bb,1,1
或是
sql = "select * from 表名"
rs.open sql,bb,1,1
if rs.eof and rs. bof then
这句呢你应该改成下面的形式:
if not rs.eof and not rs.bof then
或
if rs.eof or rs.bof then