• 存储过程的参数默认值的问题


    存储过程的参数默认值如果有填的话,在.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的值为存储过程中的默认值(即:'哈哈')

  • 相关阅读:
    JAVA Number类
    ConcurrentHashMap.Segment源码解析
    Java Concurrent包初探
    JAVA枚举类
    构造不可变类及其优点
    Unsafe类初探
    Paxos made simple 翻译尝试
    平行二叉堆和优先队列
    Android OpenCV学习
    Android-Java和HTML5交互-混合开发-优化
  • 原文地址:https://www.cnblogs.com/SALIN/p/1603854.html
Copyright © 2020-2023  润新知