• ParameterDirection.ReturnValue用法


    SqlCommand mycom = usercommon.createcommand();
             mycom.CommandText = "ModifyUserPwd";
             SqlParameter[] parm ={ new SqlParameter("@username", SqlDbType.VarChar, 50), new SqlParameter("@userpwd", SqlDbType.VarChar, 50), new SqlParameter("@newpwd", SqlDbType.VarChar, 50),new SqlParameter("@returnvalue",SqlDbType.Int) };
             parm[0].Value=username;
             parm[1].Value=oldpwd;
             parm[2].Value=newpwd;
             parm[3].Direction = ParameterDirection.ReturnValue;
             usercommon.AttachParameters(mycom,parm);
             mycom.ExecuteNonQuery();
             int i =(Int32) mycom.Parameters["@returnvalue"].Value;
             usercommon.CloseConn();
             return i;

    alter proc ModifyUserPwd
    (
    @username varchar(50),
    @userpwd varchar(50),
    @newpwd varchar(50)
    )
    as
    declare @pwd varchar(50)
    select @pwd=userpwd from users
    if(@pwd=@userpwd)
    begin
    update users set userpwd=@newpwd where username=@username
    return 1
    end
    else
    return 0
    go
  • 相关阅读:
    GUI编程
    网络编程
    线程池详解_3
    多线程详解_2
    注解和反射_1
    多线程详解_1
    javaEE简要总结
    MarkDown使用教程简单介绍
    com.sun.xxx.utils不存在问题的解决
    解决npm install安装慢的问题
  • 原文地址:https://www.cnblogs.com/bobo41/p/3097055.html
Copyright © 2020-2023  润新知