4月份开始接触SQL2000,因为要调用存储过程,所以学习了一下.以前觉得很麻烦.看到存储过程都不怎么想学习.总觉得成千上万行的代码对我来说很难很难.不愿意去学习.工作上需要.所以从网络上找了点资源.然后自己写了一个简单的ASP调用存储过程的代码.
<%
starttime=timer()
strconn = "PROVIDER=SQLOLEDB.1;Data Source='XQF222';Initial Catalog='website';Persist Security Info=True;User ID='webuser';Password='123456';Connect Timeout=30"
Set conn=Server.CreateObject("Adodb.Connection")
conn.Open strConn
if err then response.Write(err.description)
set rs=server.CreateObject("Adodb.recordset")
sql="exec sp_GetTopUserName 10"
'调用存储过程sp_GetTopUserName来查询UserID=10的会员名称
rs.open sql,conn,3,3
if rs.eof and rs.bof then
response.Write("没有查询到该记录")
else
response.Write(rs("UserName"))
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
'存储过程代码如下
CREATE PROCEDURE sp_GetTopUserName @UserID int output AS
SELECT UserName
FROM SystemUserList
WHERE UserID=@UserID
%>
ASP调用存储过程简单代码