开发者

Internationalization and parameterized queries

I make a DataSet and DataTable in C# and then make a report for a SQL Server DB (I Use Report Viewer). I need to search Value field in DataBase when my Value is English Like "test" every thing is be OK, but when my value is Arabic\Persian\Farsi the report viewer开发者_C百科 dosen't show me anything.

My query is this:

SELECT DetailsProducts.DarSad, Materials.Material, Products.Product
FROM DetailsProducts INNER JOIN
    Materials ON DetailsProducts.MaterialID = Materials.ID INNER JOIN
    Products ON DetailsProducts.ProductID = Products.ProductID
WHERE (Products.Product = @Product)

When I need one value I can use this query:

SELECT DetailsProducts.DarSad, Materials.Material, Products.Product
FROM DetailsProducts INNER JOIN
    Materials ON DetailsProducts.MaterialID = Materials.ID INNER JOIN
    Products ON DetailsProducts.ProductID = Products.ProductID
WHERE (Products.Product =N'بطری') //(Bottle = بطری)

It is OK, but this " N'exp' " dose not work when I Use Parameters. How can I fix this?


Try to create your parameter with SqlDbType equal to SqlDbType.NVarChar:

SqlParameter parameter = new SqlParameter();
parameter.ParameterName = "@Product";
parameter.SqlDbType = SqlDbType.NVarChar;
parameter.Direction = ParameterDirection.Input;
parameter.Value = "بطری";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜