小 牛

博客园 首页 新随笔 联系 订阅 管理

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



posted on 2006-07-22 16:26  csu02  阅读(550)  评论(0编辑  收藏  举报