日期:2014-05-19  浏览次数:20410 次

SQL中用ASP创建临时存储过程出错
<html>  
<head>  
<title>
</title>  
</head>  
<body>  
<%  
response.write   " <center> <font   face= " "隶书 " "size=+2> 查询结果 </font> </center> "  
DIM   qucol,str,str5  
qucol=request.form( "leixing ")  
str=request.form( "keyword ")  
str5=qucol& "LIKE "& " " "% "&str& "% " " "  
Set   Conn=Server.CreateObject( "ADODB.Connection ")  
Conn.Open   "provider=sqloledb;data   source=127.0.0.1;UID=sa;PWD=;DATABASE=pubs "  
for   I=0   to   conn.errors.count-1  
response.write   conn.errors(I).description& " <br> "  
next  
CommandText= "CREATE   PROCEDURE   #query "&session( "num ")& "AS   select   *   From   authors   Where "&str5  
Conn.execute   CommandText,0,-1  
Set   rs=Server.CreateObject( "ADODB.RecordSet ")  
Const   adOpenDynamic=2  
Const   adLockOptimistic=3  
const   adComdStoredProc=8  
CommandText= "#query "&session( "num ")  
session( "num ")=session( "num ")+1  
rs.Open   CommandText,Conn,adOpen  
Dynamic,adLockOptimistic,adComdStoredProc  
response.write   " <table   border= " "1 " "> "  
response.write " <tr> "  
for   I=0   to   rs.fields.count-1  
response.write   " <td> "&rs(I).Name& " </td> "  
next  
response.write   " </tr> "  
while   not   rs.EOF  
response.write " <tr> "  
for   I=0   to   rs.fields.count-1  
css=rs(I).value  
if   css <> " "   then  
response.write   " <td> "&css& " </td> "  
else  
response.write   " <td> . </td> "  
end   if  
next  
rs.moveNext  
response.write   " </tr> "  
Wend  
response.write " </table> "  
rs.close  
set   rs=nothing  
set   Conn=nothing  
%>  
<!--   查询结束,返回输入界面,开始下次查询   -->  
<a   href= "input.html "> 返回到查询 </a>  
</body>  
</html>  

错误类型:
Microsoft   OLE   DB   Provider   for   SQL   Server   (0x80040E14)
在关键字   'select '   附近有语法错误。
/query.asp,   第   19   行

------解决方案--------------------
少了空格

& " AS
------解决方案--------------------
str5=qucol& " LIKE "& " " "% "&str& "% " " "
CommandText= "CREATE PROCEDURE #query "&session( "num ")& " AS select * From authors Where "&str5
上面两句换了,str=request.form( "keyword ") 没有获得值