zoukankan      html  css  js  c++  java
  • 存储过程的参数默认值的问题

    存储过程的参数默认值如果有填的话,在.net里面不写这个参数的SqlParameter,直接使用的是他在存储过程的默认值存储,但是如果该参数没有默认值的话,在.net代码里面一定要写对应的SqlParameter,否则会出错。

    如存储过程sp_insert_info

    ALTER PROCEDURE dbo.sp_insert_info
    @info_id int output,
    @info_citycode nvarchar(50),
    @info_areacode nvarchar(50),
    @info_gqlxid int,
    @info_gqlbid int,
    @info_price nvarchar(50)='哈哈',
    @info_title nvarchar(50),
    @info_content nvarchar(1000),

    cs代码写里面

                SqlParameter[] parameters = {
         new SqlParameter("@info_id", SqlDbType.Int,4),
         new SqlParameter("@info_citycode", SqlDbType.NVarChar,50),
         new SqlParameter("@info_areacode", SqlDbType.NVarChar,50),
         new SqlParameter("@info_gqlxid", SqlDbType.Int,4),
         new SqlParameter("@info_gqlbid", SqlDbType.Int,4),
         new SqlParameter("@info_title", SqlDbType.NVarChar,50),
         new SqlParameter("@info_content", SqlDbType.NVarChar,1000)};

                parameters[0].Direction = ParameterDirection.Output;
                parameters[1].Value = model.info_citycode;
                parameters[2].Value = model.info_areacode;
                parameters[3].Value = model.info_gqlxid;
                parameters[4].Value = model.info_gqlbid;
                parameters[5].Value = model.info_title;
                parameters[6].Value = model.info_content;

    完成可以执行,参数info_price的值为存储过程中的默认值(即:'哈哈')

  • 相关阅读:
    高斯消元法求逆矩阵
    二分法
    Boost库
    sorts
    排序算法_HeapSort
    粒子系统之概述_20140101
    新年祝福!_20140101
    思维_逆向的魅力2_20131229
    思维_逆向的魅力_20131229
    编码能力的提升?_20131228
  • 原文地址:https://www.cnblogs.com/SALIN/p/1603854.html
Copyright © 2011-2022 走看看