我有口音的问题(例如:é、à、è 等)。当我直接插入 SQL Server 2008 Management
INSERT INTO LETTRE_VOIT (LIB_PORT) VALUES ('Payé')
时,它运行良好。但是当我在 C# 上加载此语法时,它不起作用。
try
{
using (var connectionWrapper = new Connexion())
{
var connectedConnection = connectionWrapper.GetConnected();
string sql_Syntax = Outils.LoadFileToString(HttpContext.Current.Server.MapPath("~/SQL/UpdateEtClotureList.sql"));
SqlCommand comm_Command = new SqlCommand(sql_Syntax, connectionWrapper.conn);
comm_Command.Parameters.AddWithValue("@CHAUFFEUR", CHAUFFEUR);
comm_Command.Parameters.AddWithValue("@Trans", ClotList);
string IdOrdre = "";
SqlDataReader readerOne = comm_Command.ExecuteReader();
while (readerOne.Read())
{
if (IdOrdre != "") IdOrdre += ",";
IdOrdre += readerOne["NO_ORDRE"].ToString();
}
return IdOrdre;
}
}
catch (Exception excThrown)
{
throw new Exception(excThrown.Message);
}
UpdateEtClotureList.sql 的内容:
DECLARE @AfterUpdate table (
NO_ORDRE_Temp int NOT NULL,
CODE_DEST_Temp varchar(10) NOT NULL,
DATE_CLOTUR_Temp datetime NOT NULL,
CODE_CLIENT_Temp varchar(20) NOT NULL,
MODAL_MODE_Temp char(1) NOT NULL,
MODAL_PORT_Temp bit NOT NULL,
LIVRS_EXPRS_Temp bit NOT NULL,
ENLEV_UNITE_Temp int NOT NULL,
NBR_COLIS_Temp int NOT NULL,
POID_Temp decimal(10, 2) NOT NULL,
ENLEV_CREMB_Temp decimal(10, 2) NULL,
ENLEV_DECL_Temp decimal(10, 2) NULL
)
UPDATE ORDRE
SET STATUT_ORDRE = 2, DATE_CLOTUR = GETDATE(), CHAUFFEUR = @CHAUFFEUR
OUTPUT inserted.NO_ORDRE, inserted.CODE_DEST, inserted.DATE_CLOTUR, inserted.CODE_CLIENT, inserted.MODAL_MODE, inserted.MODAL_PORT,inserted.LIVRS_EXPRS,inserted.ENLEV_UNITE, inserted.NBR_COLIS,inserted.POID,inserted.ENLEV_CREMB,inserted.ENLEV_DECL INTO @AfterUpdate
WHERE STATUT_ORDRE = 1 AND (TRANSPORTEUR IN (SELECT ParsedString From dbo.ParseStringList(@Trans)))
INSERT INTO LETTRE_VOIT
OUTPUT inserted.NO_ORDRE
select rsVoit.NOID, NO_ORDRE_Temp, rsOrdre.CODE_DEST_Temp,rsOrdre.DATE_CLOTUR_Temp, rsOrdre.CODE_CLIENT_Temp, rsOrdre.MODAL_MODE_Temp, rsOrdre.MODAL_PORT_Temp,
CASE rsOrdre.MODAL_PORT_Temp
WHEN 'false' THEN 'Payé'
ELSE 'Du'
END,
rsOrdre.LIVRS_EXPRS_Temp,
CASE rsOrdre.LIVRS_EXPRS_Temp
WHEN 'false' THEN 'Long'
ELSE 'Express'
END,
rsOrdre.ENLEV_UNITE_Temp, LIBELLE, NBR_COLIS_Temp,POID_Temp,ENLEV_CREMB_Temp,ENLEV_DECL_Temp
from @AfterUpdate rsOrdre
inner join
(
select CODE_DEST,MODAL_MODE, MODAL_PORT, LIVRS_EXPRS,ENLEV_UNITE, ROW_NUMBER() over (order by CODE_DEST) as NOID
from ORDRE
group by CODE_DEST,MODAL_MODE,MODAL_PORT,LIVRS_EXPRS,ENLEV_UNITE
) rsVoit on rsVoit.CODE_DEST = rsOrdre.CODE_DEST_Temp and rsVoit.MODAL_MODE = rsOrdre.MODAL_MODE_Temp
and rsVoit.MODAL_PORT = rsOrdre.MODAL_PORT_Temp and rsVoit.LIVRS_EXPRS = rsOrdre.LIVRS_EXPRS_Temp
and rsVoit.ENLEV_UNITE = rsOrdre.ENLEV_UNITE_Temp
LEFT JOIN T_UNITE ON rsOrdre.ENLEV_UNITE_Temp = T_UNITE.NOID
order by rsVoit.NOID, NO_ORDRE_Temp
结果是 Pay*,而不是 Payé , * 是一个方形符号。
提前谢谢你。
PS:我使用 nvarchar 而不是 varchar 类型
当我更改语法时:
....
CASE rsOrdre.MODAL_PORT_Temp
WHEN 'false' THEN N'Payé'
ELSE 'Du'
END,
rsOrdre.LIVRS_EXPRS_Temp,
.....
我有:
当我通过 SQL Profiler 查看时: