zoukankan      html  css  js  c++  java
  • SqlParameter 存储过程

     public static int AddStudent(Student stu)
            {
                int num = 0;

               //关键是存储过程
                string sql = "addNewStudent";
                SqlParameter p=new SqlParameter();
                p.ParameterName="@newId";
                p.SqlDbType=SqlDbType.Int;
                p.Direction=ParameterDirection.Output;
                bool sex=stu.StuSex=="男"?true:false;
                SqlParameter[] param={new SqlParameter("@name",stu.StuName),
                                     new SqlParameter("@sex",sex),
                                     new SqlParameter("@birthday",stu.StuBirthday),
                                     new SqlParameter("@hight",stu.StuHeight),
                                     new SqlParameter("@weight",stu.StuWeight),
                                     new SqlParameter("@cid",stu.ClassId),
                                     new SqlParameter("@money",stu.Money),
                                     new SqlParameter("@password",stu.StuPwd),
                                     new SqlParameter("@memo",stu.Remark),
                                     new SqlParameter("@rid",stu.RoleId),p};
                num = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStr, CommandType.StoredProcedure, sql, param);
                if (num > 0)
                {
                    return int.Parse(p.Value.ToString());
                }
                else
                {
                    return -1;
                }
            }

    风雪七月花溅墨
  • 相关阅读:
    UpdateParameterUtils
    从WAVE头文件里获取压缩方式
    oracle rac下调节redo log file 文件大小
    centos下yum安装lamp和lnmp轻松搞定
    回车登录(支持IE 和 火狐等浏览器)
    图结构练习——推断给定图是否存在合法拓扑序列(拓扑排序推断环)
    HDU 2181 DFS
    Android 运行 gson.toJson(object) 报java.lang.StackOverflowError异常
    Spring-SpringJdbcTemlate配置介绍
    Cocos2D-x设计模式发掘之中的一个:单例模式
  • 原文地址:https://www.cnblogs.com/bobo41/p/3068427.html
Copyright © 2011-2022 走看看