简体   繁体   中英

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. It appears that the returned value is now including the extra white spaces to return a full 100 characters. 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. Select statements for varchar columns return just the values in the columns and no extra white spaces. Ansi_padding is off for the database and is not set any where in the code.

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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