这个存储过程是否有不妥?列值变列名了!
存储过程如下:调用却提示错误 ,症状如下
'=====================================
提交表单后,各参数值
Tablenum="admin"
Username="john"
UserPassword="123456"
一运用存储过程 就提示 列名“john”无效
john明明是 username 列 的值 ,怎么变成了 表的列?
'=====================================
CREATE PROCEDURE UserLogin
@Tablenum varchar(50),
@Username varchar(50),
@UserPassword varchar(50),
@iReturn int output
as
DECLARE @SqlStr NVARCHAR(1000)
set @SqlStr="select * from ["+ @Tablenum + "] where [username] = "+@Username
exec(@SqlStr )
if(@@rowcount <1)
begin
set @iReturn=0
end
else
begin
set @SqlStr="select * from ["+@Tablenum+"] where [username]= "+@Username+" and [password] = "+@UserPassword
exec(@SqlStr )
if(@@rowcount <1)
begin
set @iReturn=1
end
else
begin
set @iReturn=2
end
end
GO
[[it] 本帖最后由 kira007 于 2008-11-11 13:23 编辑 [/it]]