ITPub博客

首页 > 应用开发 > IT综合 > 返回存儲過程的多個輸出字段

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

原创 IT综合 作者:erpcsu02 时间:2007-01-19 19:35:12 1 删除 编辑

存儲過程:
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;
}

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8690328/viewspace-891764/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-10-11

  • 博文量
    31
  • 访问量
    335160