关闭

返回存儲過程的多個輸出字段

494人阅读 评论(0) 收藏 举报

存儲過程:
CREATE procedure User_Login
@user_id varchar(20),
@password varchar(50),
@Return_Status char(1) output,
@user_name varchar(20) output,
@dept varchar(20) output,
@duty varchar(20) output,@Evaluate varchar(1)='N' output
AS
declare @dept_id varchar(4)
declare @duty_id varchar(4)
select @dept=''
select @duty=''
select @user_name=''
select @return_status='0' --不知明錯誤

if exists(select user_id from user_list where user_id=@user_id)
begin
if exists(select user_id from user_list where user_id=@user_id and password=@password)
begin
select @user_name=user_name,@dept_id=dept_id,@duty_id=duty_id,@Evaluate=is_Evaluate from user_list where user_id=@user_id and password=@password
select @dept=sname from dept_list where dept_id=@dept_id
select @duty=sname from duty_list where duty_id=@duty_id
select
@return_status='3'--正確登錄
end
else
select @return_status='2'--密碼錯誤
end
else
select @return_status='1'--用戶名不存在
GO

方法:
public string[] user_login(string user_id,string password)
{ mabuchi.Class.SqlHelper sqlhelper = new SqlHelper();
string [] erp = new string [5]; //接收数组
SqlParameter [] paramlist = { sqlhelper.CreateInParam("@User_id",SqlDbType.VarChar,20,user_id),
sqlhelper.CreateInParam("@password",SqlDbType.VarChar,50,password),
sqlhelper.CreateOutParam("@Return_Status",SqlDbType.VarChar,1),
sqlhelper.CreateOutParam("@user_name",SqlDbType.VarChar,1),
sqlhelper.CreateOutParam("@dept",SqlDbType.VarChar,20),
sqlhelper.CreateOutParam("@duty",SqlDbType.VarChar,20),
sqlhelper.CreateOutParam("@Evaluate",SqlDbType.VarChar,1)
};
try
{
sqlhelper.RunProc("User_Login ",paramlist);
erp[0] = paramlist[0].Value.ToString();
...
erp[4] = parmlist[6].Value.ToString();
return erp;
}

 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:38846次
    • 积分:586
    • 等级:
    • 排名:千里之外
    • 原创:18篇
    • 转载:9篇
    • 译文:3篇
    • 评论:3条
    最新评论