标签:代码 ORC Nid 控制 date() 乱码 port return var
1、出现乱码的场景如下:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
1)c#代码如下:
private int InsertBaseReport(int year, long mainId, Guid? orgId, DateTime repordate, string indictorCode, string dataValue)
{
string insertSql =
$"insert into T_Report_Base{year} (F_MainID,F_OrgID,F_ReportDate,F_IndicatorCode,F_Value,F_LastDateTime) " +
$"values({mainId},‘{orgId}‘,‘{repordate}‘,‘{indictorCode}‘,‘{dataValue}‘,getdate())";
return db.Database.ExecuteSqlCommand(insertSql);
}
2)数据库字段设计F_Value类型varchar(100)
3)结果:F_Value字段出现乱码
2、解决方案:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
1)c#代码修改如下:
private int InsertBaseReport(int year, long mainId, Guid? orgId, DateTime repordate, string indictorCode, string dataValue)
{
string insertSql =
$"insert into T_Report_Base{year} (F_MainID,F_OrgID,F_ReportDate,F_IndicatorCode,F_Value,F_LastDateTime) " +
$"values({mainId},‘{orgId}‘,‘{repordate}‘,‘{indictorCode}‘,N‘{dataValue}‘,getdate())";
return db.Database.ExecuteSqlCommand(insertSql);
}
2)数据库字段设计F_Value类型修改为nvarchar(100)
3) 将控制面板中->区域 设置更改为中文(简体,中国)
标签:代码 ORC Nid 控制 date() 乱码 port return var
原文地址:https://www.cnblogs.com/anibei/p/10747584.html