【问题标题】:How to save breakeline in DataBase and show it in textarea winform c#如何在DataBase中保存breakeline并在textarea winform c#中显示它
【发布时间】:2019-04-16 11:46:39
【问题描述】:

我在数据库中保存了一个长字符串,我想在我的 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# sql sql-server winforms


【解决方案1】:

假设这是针对 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

【讨论】:

【解决方案2】:

因为它们不是这样渲染的。

将代码中的\r\n 替换为Environment.NewLine

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    相关资源
    最近更新 更多