• 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;
                }
            }

    风雪七月花溅墨
  • 相关阅读:
    shell编程-项目部署(优化篇)
    数据库相关
    python基础面试
    scrapy爬取数据进行数据库存储和本地存储
    C# 对字符串操 替换数字 替换非数字 去除首尾字符 长沙
    还在为删除集合中的相同项而烦恼吗?
    C#之Task&匿名方法
    如何在火狐里面实现如下功能
    valueOf和toString曾经欺骗过你吗?
    JS 实现Json查询方法
  • 原文地址:https://www.cnblogs.com/bobo41/p/3068427.html
Copyright © 2020-2023  润新知