在将数据插入数据库时​​,最后会添加单个空格? [英] Single white space is adding at the end while inserting data into DB?

查看:174
本文介绍了在将数据插入数据库时​​,最后会添加单个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

While inserting data into a table using .Net entity framework stored procedure call a white space is appending at the end. this issue is with two columns only.
where both the columns are having a Foreign Key to different tables (the tables will have allowable values (constants)). 
FYI.

 1. column 1 is defined as varchar(6) and column 2 is defined varchar (3) in sql DB.
 2. but the foreign  key table 1 is having data with max length is 4, table 2 is having data with max length is 3.
 3.  in EDMX file below code is available 

a) 

    <Function Name="spInsertdetails" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
            <Parameter Name="column1" Type="char" Mode="In" />
            <Parameter Name="column2" Type="char" Mode="In" />
    
    b) <FunctionImport Name="spInsertdetails" ReturnType="Collection(TestDBModel.spInsertdetails_Result)">
                <Parameter Name="column1" Mode="In" Type="String" />
                <Parameter Name="column2" Mode="In" Type="String" />

Please let me know if any further details required.





我尝试过:





What I have tried:

in 3.a) i have tried changing the char to varchar but the issue still present.

推荐答案

We need to change datatype to varchar in both Stored procedure as well in entity framework edmx, then in 3)a Function it will change to varchar, so it will not append space at the end.


这篇关于在将数据插入数据库时​​,最后会添加单个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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