这么一个简单的存储过程我怎么搞也不对,晕(言者有分,共100分)
提取特定表的id记录的信息
CREATE proc teb_id
@teblename varchar(50), --表名--
@id varchar(50), --记录id号--
@tebzd varchar(500) --所要取得的字段--
as
declare @strSQL varchar(5000)
begin
if @tebzd = ' '
begin
set @strSQL= 'select * from [ '+ @teblename + '] where id= ' + @id + ' '
exec (@strSQL)
end
else
begin
set @strSQL= 'select ' +@tebzd+ ' from [ '+ @teblename + '] where id= ' + @id + ' '
exec (@strSQL)
end
end
GO
前台asp页面我是这样调用的:
<!--#include file= "conn/conn.asp "-->
dim zd
zd= " id,title,comn "
set rs = server.createobject( "adodb.recordset ")
rs.Open "EXEC teb_id info "&request( "id ")& ", ' "&zk& " ' " ,conn,1,1
可怎么搞也不搞不对,晕了
------解决方案--------------------zd= " id,title,comn "
--> comn, 应该是conn吧
------解决方案-------------------- "&zk& "写错了吧,是zd吧
可以这样调用存储过程
Set oCommand = CreateObject( "ADODB.Command ")
sID = request( "id ")
zd = " id,title,comn "
With oCommand
.CommandText = "teb_id "
.CommandType = 4
Set oPara = .CreateParameter( "@teblename ", 200, 1, 50, "info ")
.Parameters.Append oPara
Set oPara = .CreateParameter( "@id ", 200, 1, 50,sID)
.Parameters.Append oPara
Set oPara = .CreateParameter( "@tebzd ", 200, 1, 500,zd)
.Parameters.Append oPara
Set .ActiveConnection = conn
Set rs = .Execute
Set .ActiveConnection = Nothing
------解决方案--------------------赞成楼上,我调用存储过程都是那样的