我的 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/