c# - SQL 查询找不到以 č、ć、š、ž 等开头的城市

标签 c# sql sqlite character-encoding

我的 SQL 查询没有找到以例如 č 开头的城市,但确实找到了名称中有 č 但以常规英文字母开头的城市。

数据库中City列是nvarchar类型。

这个问题的解决方案是什么?

我正在使用 SQLite 数据库。

    cmdSQLite = new SQLiteCommand("SELECT RegistrationNumber, DocumentName, 
    Performer, BuiltYear, ReferatCardNumber , City, Municipalities , StreetName 
    FROM Geotest WHERE LOWER (City) = @City", connectionSQLite);

    SQLiteParameter parameterCity = new SQLiteParameter();
    parameterCity.Value = comboBoxCitySearch.Text.ToLower();
    parameterCity.ParameterName = "@City";
    cmdSQLite.Parameters.Add(parameterCity);

最佳答案

我认为您的问题可能与 SQL Server 中的 unicode 字符串有关。这可能有帮助

http://support.microsoft.com/kb/239530

When dealing with Unicode string constants in SQL Server you must precede all Unicode strings with a capital letter N, as documented in the SQL Server Books Online topic "Using Unicode Data". The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase. If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.

更新:我的错误,我没有正确阅读问题,我以为我们在谈论 SQL Server。阅读 SQL Lite 文档,http://www.sqlite.org/faq.html#q18

The default configuration of SQLite only supports case-insensitive comparisons of ASCII characters. The reason for this is that doing full Unicode case-insensitive comparisons and case conversions requires tables and logic that would nearly double the size of the SQLite library. The SQLite developers reason that any application that needs full Unicode case support probably already has the necessary tables and functions and so SQLite should not take up space to duplicate this ability.

关于c# - SQL 查询找不到以 č、ć、š、ž 等开头的城市,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7626403/

相关文章:

mysql 相当于低版本中的公用表表达式(CTE)

c# - 当我更改设置的漫游属性时,如何保留用户设置的值?

c# - 如何获得 HLSL 计算的输出?

mysql - mysql需要的所有条件数据

sql - 雪花数据仓库的 SELECT INTO 语法

sqlite - 存储我的服务 sqlite 数据库文件的最佳位置?

ruby-on-rails - Ruby on rails - 参数数量错误(2 为 1)[Rails]

android - 如何使用 android sqlite 和 contentvalue 进行批量替换

C# Hashtable 不保留值

c# - 如果创建了一个未显示的窗口,应用程序不会退出