请问这存储过程怎么调用?用asp代码写
key=Request.QueryString("key")setrs=server.createobject("adodb.recordset")sql="select...
key=Request.QueryString("key")
set rs=server.createobject("adodb.recordset")
sql="select top 1 id from [easou] where sjname='"&key&"'"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
rs.addnew
rs("sjname")=key
rs.update
else
response.redirect "/f.asp?fid="&rs("id")&""
end if
rs.close
sql="select top 1 * from [easou] where sjname='"&key&"'"
rs.open sql,conn,1,3
fid=rs("id")
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect "/f.asp?fid="&fid&""
以上这个代码写成下面的存储过程
create proc sp_GetSjId( @sjname varchar(20))
AS
BEGIN
declare @id int
if exists(select id from easou where sjname=@sjname)
begin
set @id=(select id from easou where sjname=@sjname)
end
else
begin
insert into easou(sjname)values(@sjname)
set @id=@@identity
end
select @id
End
go
请问这个存储过程用asp代码怎么调用? 尽量详细 展开
set rs=server.createobject("adodb.recordset")
sql="select top 1 id from [easou] where sjname='"&key&"'"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
rs.addnew
rs("sjname")=key
rs.update
else
response.redirect "/f.asp?fid="&rs("id")&""
end if
rs.close
sql="select top 1 * from [easou] where sjname='"&key&"'"
rs.open sql,conn,1,3
fid=rs("id")
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect "/f.asp?fid="&fid&""
以上这个代码写成下面的存储过程
create proc sp_GetSjId( @sjname varchar(20))
AS
BEGIN
declare @id int
if exists(select id from easou where sjname=@sjname)
begin
set @id=(select id from easou where sjname=@sjname)
end
else
begin
insert into easou(sjname)values(@sjname)
set @id=@@identity
end
select @id
End
go
请问这个存储过程用asp代码怎么调用? 尽量详细 展开
展开全部
不是很明白
Function SP_GETSJID(key)
Set rs=server.createobject("adodb.recordset")
sql="SELECT top 1 id FROM [easou] WHERE sjname='"&key&"'"
rs.open sql,conn,1,3
IF rs.eof AND rs.bof THE
rs.addnew
rs("sjname")=key
rs.update
Else
response.redirect "/f.asp?fid="&rs("id")&""
End Function
End if
rs.Close
sql="SELECT top 1 * FROM [easou] WHERE sjname='"&key&"'"
rs.open sql,conn,1,3
fid=rs("id")
rs.close
set rs=nothing
response.redirect "/f.asp?fid="&fid&""
End Function
这样?
Function SP_GETSJID(key)
Set rs=server.createobject("adodb.recordset")
sql="SELECT top 1 id FROM [easou] WHERE sjname='"&key&"'"
rs.open sql,conn,1,3
IF rs.eof AND rs.bof THE
rs.addnew
rs("sjname")=key
rs.update
Else
response.redirect "/f.asp?fid="&rs("id")&""
End Function
End if
rs.Close
sql="SELECT top 1 * FROM [easou] WHERE sjname='"&key&"'"
rs.open sql,conn,1,3
fid=rs("id")
rs.close
set rs=nothing
response.redirect "/f.asp?fid="&fid&""
End Function
这样?
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
直接conn.execute("exec sp_GetSjId 参数")就可以了,如果要有返回的结果集就用set rs = conn.execute("exec sp_GetSjId 参数")
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public void Demo(string sjname)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_GetSjId";
SqlParameter[] sp ={
new SqlParameter("@sjname",SqlDbType.VarChar)
};
sp[0].Value = sjname;
}
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_GetSjId";
SqlParameter[] sp ={
new SqlParameter("@sjname",SqlDbType.VarChar)
};
sp[0].Value = sjname;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询