zoukankan      html  css  js  c++  java
  • string[1]:size 属性具有无效大小值0

    截图 使用存储过程返回多个字符串参数

    程序

         public class EventStatisticsDAL
        {
    
            public static void GetCount(string code, out string SC, out string DC, out string SSC, out string RPC)
            {
                SqlParameter[] parameter = new SqlParameter[] { 
                    
                      new SqlParameter("@DistrictCode",SqlDbType.NVarChar),
                      new SqlParameter("@SC",SqlDbType.NVarChar,50),
                      new SqlParameter("@DC", SqlDbType.NVarChar,50),
                      new SqlParameter("@SSC", SqlDbType.NVarChar,50), 
                      new SqlParameter("@RPC", SqlDbType.NVarChar,50), 
                };
                parameter[0].Value = code;
                for (int i = 1; i < parameter.Length; i++)
                {
                    parameter[i].Direction = ParameterDirection.Output;
                }
    
                List<Self_EventCount> countList = new List<Self_EventCount>();
               SqlHelper.GetTable("SelectEventCount", CommandType.StoredProcedure, parameter);
               SC = Convert.ToString(parameter[1].Value);
               DC = Convert.ToString(parameter[2].Value);
               SSC = Convert.ToString(parameter[3].Value);
               RPC = Convert.ToString(parameter[4].Value);
            }
        }
    

    解决方案:输出参数需指定长度

    分析:输出参数为字符串的时候,需要指定其大小

  • 相关阅读:
    Regional Changchun Online--Elven Postman(裸排序二叉树)
    动态规划01背包记录
    hdoj 2546 饭卡
    hdoj 2553 N皇后问题【回溯+打表】
    nyoj 282 You are my brother
    hdoj 1231 最大连续子序列
    hdoj 1003 Max Sum
    2015年6月24
    poj 1338 Ugly Numbers
    poj 3979 分数加减法
  • 原文地址:https://www.cnblogs.com/leee/p/5382937.html
Copyright © 2011-2022 走看看