私のデータベースにはデータがあります。'A Plus 18" Stand Fan'
一重引用符は使用しないでください。私はデータをそのまま保存するためにnvarcharを使用しましたが、データベースから取得しようとすると、データは'A Plus 18\" Stand Fan'
を返しています。 WebUtility.HtmlDecode
とHtmlUtility.Html.Decode
でもWebUtility.UrlDecode
を使ってみました。誰か助けてくれますか?ありがとう!データベースからC#への特殊文字の取得
ここで私は比較のためにデータベースからデータを読み込みます。 「モデルは、」私は
for (int y = 0; y < dt.Rows.Count; y++)
{
model = dt.Rows[y]["ItemModel"].ToString();
string companys = "";
companys = dt.Rows[y]["Company"].ToString();
//getAMS(model, quan);
Utility a = new Utility();
string com = a.PO();
SqlConnection con = new SqlConnection(com);
SqlCommand read = con.CreateCommand();
SqlDataReader reader = null;
string stat = "Delivered";
string mod = "SELECT SUM(Quantity) as Quantity from vConsumables_Balance where Model ='" + model + "' AND Company = '" + companys + "' AND Status = 'Delivered'";
try
{
con.Open();
read.CommandText = mod;
reader = read.ExecuteReader();
}
catch (System.Exception)
{
Console.WriteLine("Error");
}
while (reader.Read())
{
quan = reader.GetDecimal(0).ToString();
}
この文字列をどのように取得したのか、より具体的に説明する必要があります。コード断片が助けになります。一般に、C#文字列の特殊文字はエスケープされます(\が先頭に付いています)。見積もりは特殊文字です。したがって、その前にバックスラッシュがあります。 –
文字列を比較する必要はありますか?文字列を表示するときにそれらがなくなるはずです –
C#コードとビュー/マークアップの一部を共有します。 –