首页 > 解决方案 > 如何在DataBase中保存breakeline并在textarea winform c#中显示它

问题描述

我在数据库中保存了一个长字符串,我想在我的 winForm 的文本区域中显示它。

但我没有得到我想要的结果。

编码:

insert into table
(
 Description
)
'ערך אחד: ' + convert(NVARCHAR, t1.MonthlyReturnAmount) +'\r\n'+
' ערך שני: ' + convert(NVARCHAR, t1.LastPaymentDate) +'\r\n'+
' ערך שלישי: ' + case WHEN t2.IsActive=0 then 'לא' else 'כן' END
from table1 t1
join table2 t2 on t1.id=t2.filed

在数据库中:

在此处输入图像描述

在文本区域:

在此处输入图像描述

而且它没有断线,为什么?

标签: c#sqlsql-serverwinforms

解决方案


假设这是针对 SQL Server 的,您可以使用该nchar()函数获取字符编号 13、回车和 10(新行)。

insert into table
(
 Description
)
'ערך אחד: ' + convert(NVARCHAR, t1.MonthlyReturnAmount) + nchar(13) + nchar(10) +
' ערך שני: ' + convert(NVARCHAR, t1.LastPaymentDate) + nchar(13) + nchar(10) +
' ערך שלישי: ' + case WHEN t2.IsActive=0 then 'לא' else 'כן' END
from table1 t1
join table2 t2 on t1.id=t2.filed

推荐阅读