如何设置字符串的长度 [英] how to set the length of string

查看:1024
本文介绍了如何设置字符串的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有存储过程并且我已将值作为输出传递,它将返回值作为字符串但字符串仅显示长度为1但是在存储过程中我已设置长度(最大值)但输出仍然是单个

例如输出应该是mr-01-1但只显示m



商店程序被称为

 SqlParameter [] param1 = new SqlParameter [1]; 

var a = string.Empty;

列表< 对象 > objParamDetails = new List < Object > ();

SqlParameter MemberId = new SqlParameter(@ MemberId,a);
MemberId.Direction = ParameterDirection.Output;
param1 [0] = MemberId;







DataTable dt1 = new DataTable();

dt1 = CDataAccessLayer.GetDataTable(sp_5_43_GetCashReceivedPrint,param1,string.Empty,ref objParamDetails);

解决方案

你需要提一下定义参数时字符串的大小



 SqlParameter MemberId =  new  SqlParameter(  @ MemberId,System.Data.SqlDbType.VarChar, 10 ,一个); 


i have the store procedure and i have passed the value as output which will return the value as string but the string is showing only length of 1 but on store procedure i have set the length(max) but the output is still single
eg the output should be mr-01-1 but only showing m

the store procedure is called as

SqlParameter[] param1 = new SqlParameter[1];

           var a = string.Empty;

           List<Object> objParamDetails = new List<Object>();

           SqlParameter MemberId = new SqlParameter("@MemberId", a);
           MemberId.Direction = ParameterDirection.Output;
           param1[0] = MemberId;




DataTable dt1 = new DataTable();
dt1 = CDataAccessLayer.GetDataTable("sp_5_43_GetCashReceivedPrint", param1, string.Empty, ref objParamDetails);

解决方案

You need to mention the size of the string while you are defining the parameter

SqlParameter MemberId = new SqlParameter("@MemberId", System.Data.SqlDbType.VarChar,10,a);


这篇关于如何设置字符串的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆