简体   繁体   English

存储过程varchar输出参数

[英]Stored procedure varchar output parameter

Yesterday, I noticed something odd when returning a varchar(100) output parameter from my stored procedure in my asp.net application. 昨天,当我从asp.net应用程序中的存储过程返回varchar(100)输出参数时,我注意到了一些奇怪的事情。 It appears that the returned value is now including the extra white spaces to return a full 100 characters. 似乎返回的值现在包括多余的空格,以返回完整的100个字符。 This behavior is new. 此行为是新的。 The only thing I have changed recently is migrating the project from VS 2015 to 2017. I am using System.Data.SQLClient to connect to the database. 我最近更改的唯一一件事是将项目从VS 2015迁移到2017年。我正在使用System.Data.SQLClient连接到数据库。 Select statements for varchar columns return just the values in the columns and no extra white spaces. varchar列的select语句仅返回列中的值,而不返回多余的空格。 Ansi_padding is off for the database and is not set any where in the code. Ansi_padding已关闭数据库,并且未在代码中的任何位置设置。

set @Message = 'Project Updated!' --where @Message is varchar(100)

This will return to the client. 这将返回给客户端。

_UpdateStatus = oData.outputParams.Item("@Message") 
_UpdateStatus = "Project Updated!                                                                                    "

Any ideas as to what is happening? 关于正在发生的事情有什么想法吗?

惰性解决方案:

_UpdateStatus = ((string)oData.outputParams.Item("@Message")).Trim()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM