为什么不出结果??(还请各位老师帮忙!!!)

sfqczy 2004-05-05 12:32:46
我写了如下的查询代码,访问数据库,并把结果显示在客户端!但是总是不出结果,不知道为什么?还请各位仁兄帮忙!!

<!--#include file="conn.asp"-->

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>按记录编号搜索</title>
</head>

<body>
<center>
<h2>维护记录表</h2>
<table width=60% border=1>
<tr><th>序号<th>记录编号<th>客户id<th>机器编号<th>服务日期<th>到达时间<th>离开时间<th>故障描述<th>故障解决<th>服务费<th>合同内<th>工程师<th>备注<th>收款
<%
dim sqlstr,prid,cuid,rs_main
prid=request.form("prid")
cuid=request.form("cuid")
conn.open connstr
set rs_main=server.createobject("adodb.recordset")
sqlstr="select * from pr where 记录编号='"&prid&"' and 客户id='"&cuid&"'"
set rs_main=conn.Execute(sqlstr)
If not rs_main.EOF Then
' 如果recordset不为空, 则维护记录存在
Session("bolAuthenticated") = True
'将bolAuthenticated 设为True

i=0
'循环读取记录集
do while not rs_main.eof
'i 为序号
i=i+1
response.write "<tr>"
response.write "<td align=center>" &i
'显示客户资料表
response.write"<td>" & rs_main("记录编号")
response.write "<td>" & rs_main("客户id")
response.write "<td>" & rs_main("机器编号")
response.write "<td>" & rs_main("服务日期")
response.write "<td>" & rs_main("到达时间")
response.write "<td>" & rs_main("离开时间")
response.write "<td>" & rs_main("故障描述")
response.write "<td>" & rs_main("故障解决")
response.write "<td>" & rs_main("服务费")
response.write "<td>" & rs_main("合同内")
response.write "<td>" & rs_main("工程师")
response.write "<td>" & rs_main("备注")
response.write "<td>" & rs_main("收款")
rs_main.movenext
loop
response.write "</table>"
rs_main.close
set rs_main=nothing
end if
%>
</table>
</center>
</body>
</html>
表中的字段就是上面输出字段,还请各位仁兄指点迷津!!或者有比这段程序更好的麻烦转告!多谢!!!!

...全文
37 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaca 2004-05-09
  • 打赏
  • 举报
回复
sqlstr="select * from pr where 记录编号="&prid&" and 客户id="&cuid
makay 2004-05-09
  • 打赏
  • 举报
回复
原因可能出在这里:set rs_main=conn.Execute(sqlstr)

多了个set

你前面已经set rs_main=server.createObject("adodb.recordset")了,这里就不要再set了

如果还不行,你把这行改成
rs_main.open sqlstr,conn,1,1试试
sfqczy 2004-05-06
  • 打赏
  • 举报
回复
提示“20行类型不匹配“
sfqczy 2004-05-06
  • 打赏
  • 举报
回复
我的CONN.ASP中的代码是这样写的:<%
dim conn,connstr
set conn=server.createobject("adodb.connection")
connstr="provider=SQLOLEDB;DATA SOURCE=localhost;INITIAL CATALOG=sinocms;user id=sa"
%>
在运行的时候老是出现:
错误类型:
Provider (0x80020005)
类型不匹配。
/sinocms/engidresult.asp, 第 20 行
所以还请给位大哥帮帮忙!!多谢!!
lovewangshu 2004-05-06
  • 打赏
  • 举报
回复
20行是"conn.open connstr"
那你的<!--#include file="conn.asp"-->里是什么呢?没有打开connection???
stayhere 2004-05-05
  • 打赏
  • 举报
回复
4 response.write 中没有输入对应的"</td>"和"</tr>".一般的表如下:
<table .....>
<tr><td>...</td><td>....</td></tr>
<tr><td>...</td><td>....</td></tr>
.........
</table>
makay 2004-05-05
  • 打赏
  • 举报
回复
什么都没有吗?
提示什么错误没?

在If not rs_main.EOF Then
这句前分别写response.write"......"
不同的字符,看看你的程序是否执行了if not rs_main.eof then
里面的语句,缩小出错误范围.
stayhere 2004-05-05
  • 打赏
  • 举报
回复
1 set rs_main=server.createobject("adodb.recordset")这句完全不需要,但不会影响结果
2 记录编号和客户id是字符型数据吗?如果是数值型,不需要单引号.sqlstr="select * from pr where 记录编号="&prid&" and 客户id="&cuid
3 是否把conn.asp中的内容贴上来?也许是它有问题.猜想正确的应该是:

<%
set conn=server.createobject("adodb.connection")
connstr="......" '省略的是数据库连接语句
%>
lubaixu 2004-05-05
  • 打赏
  • 举报
回复
你程序中的代码conn.open connstr有何用处??
还用你的conn.asp中的程序是否有误呀?

28,391

社区成员

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

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