asp新手初连数据库 求前辈帮忙查错!

tuhuolongan 2010-04-13 08:32:02
<html>
<HEAD>
<TITLE>asp11a.asp</TITLE>
</HEAD>
<body bgcolor="#FFFFFF">
<%
call query2table("select * from publishers where name like \'A%%\'")
' 将表 publishers 中所有姓名中有字母 A 的记录查询出来
%>
<!--#include virtual="/asptest/subdbtable.inc"-->
</BODY>
</html>

下面是subdbtable.inc文件
<%
sub query2table(inputquery)
set conntemp=server.createobject("adodb.connection")
conntemp.open "DSN=longan;uid=sa;pwd=zw112358"
set rstemp=conntemp.execute(inputquery) '执行SQL语句并把返回结果保存到rstemp
howmanyfields=rstemp.fields.count -1
' 统计数据库中的列数
%>
<table border=1><tr>
<%
for i=0 to howmanyfields
%>
<td><b><%=rstemp(i).name%></B></TD>
<% next %>
</tr>
<%
do while not rstemp.eof
%>
<tr>
<% for i = 0 to howmanyfields
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue="" ' 如果字段为空,则将变量 thisvalue 的值定义为一个空格
end if%>
<td valign=top><%=thisvalue%></td>
<% next %>
</tr>
<%rstemp.movenext
loop%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothingend
end sub
%>


运行时报subdbtable.inc的第五行有语法错误如下
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]'A%%\' 附近有语法错误。
/asptest/subdbtable.inc, 第 5 行
...全文
74 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tuhuolongan 2010-04-14
  • 打赏
  • 举报
回复
睡了一觉早上一来问题就解决了 哈!哈!
<html>
<HEAD>
<TITLE>asp11a.asp</TITLE>
</HEAD>
<body bgcolor="#FFFFFF">
<%
call query2table("select * from [longan].[dbo].[publishers] where name like '%A%'")
' 将表 publishers 中所有姓名中有字母 A 的记录查询出来
%>
<!--#include virtual="/asptest/subdbtable.inc"-->
</BODY>
</html>

<%
sub query2table(inputquery)
set conntemp=server.createobject("adodb.connection")
conntemp.open "DSN=longan;uid=sa;pwd=zw112358"
set rstemp=conntemp.execute(inputquery) '执行SQL语句并把返回结果保存到rstemp
howmanyfields=rstemp.fields.count -1
' 统计数据库中的列数
%>

<table border=1><tr>
<%
for i=0 to howmanyfields
%>
<td><b><%=rstemp(i).name%></B></TD>
<% next %>
</tr>
<%
do while not rstemp.eof
%>
<tr>
<% for i = 0 to howmanyfields
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue="" ' 如果字段为空,则将变量 thisvalue 的值定义为一个空格
end if%>
<td valign=top><%=thisvalue%></td>
<% next %>
</tr>
<%rstemp.movenext
loop%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
conntemp=nothingend
end sub
%>

结贴咯!!
tuhuolongan 2010-04-13
  • 打赏
  • 举报
回复
改了后报这样的错
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC SQL Server Driver][SQL Server]对象名 'publishers' 无效。
/asptest/subdbtable.inc, 第 5 行
soswaidao 2010-04-13
  • 打赏
  • 举报
回复
友情帮顶~~~~
孟子E章 2010-04-13
  • 打赏
  • 举报
回复
call query2table("select * from publishers where name like '%A%'")
tuhuolongan 2010-04-13
  • 打赏
  • 举报
回复
怎么都没人啦 我的问题还没解决啊 纠结~~~

28,391

社区成员

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

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