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

一个存储过程的问题
数据表结构如下:
3 id                 int 4 0
0 userfrom varchar 50 1
0 xuhao                 char 100 1
0 thetime                 char 100 1

存储过程:
CREATE   PROCEDURE   dbo.getid
              @Userfrom   varchar(40)
        as
        begin
              if   @Userfrom   is   null   return
              select     *
                      from   dbo.[log]  
                      where   Userfrom= '@Userfrom '
              return
        end
GO

页面代码:
<!--#include   file= "conn.asp "-->
<%
DIM   MyComm,id,userid,Userfrom
id=1
userfrom= "127.0.0.1 "

Set   MyComm   =   Server.CreateObject( "ADODB.Command ")
MyComm.ActiveConnection   =   conn     'MyConStr是数据库连接字串
MyComm.CommandText     =   "getid "   '指定存储过程名
MyComm.CommandType     =   4   '表明这是一个存储过程
MyComm.Prepared   =   true     '要求将SQL命令先行编译
'声明参数
MyComm.Parameters.append   MyComm.CreateParameter( "@Userfrom ",200,1,40,userfrom)
Set   MyRst   =   MyComm.Execute
do   while   not   MyRst.eof
i=i+1
MyRst.movenext
loop
response.write   i
Set   MyComm   =   Nothing
%>

设计功能是统计这个表中   ID为:userfrom   的记录的条数,运行的时候报错:

脚本超时

请大家给予帮助,谢谢先。

------解决方案--------------------
select *
from dbo.[log]
where Userfrom=@Userfrom --不用 ' '
------解决方案--------------------
在查询分析器里边直接使用
exec getid '127.0.0.1 '
直接试试看 ,如果没有问题则是你有的web服务器配置问题
如果有问题就分析一下错误信息