SQL 查询找不到以 č、ć、š、ž 等开头的城市
我的 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);
My SQL query doesn't find cities that begin with for instance č, but does find cities which have č in their name but begin with regular English letters.
The City column in the database is of nvarchar type.
What is the solution for this problem?
I am using an SQLite database.
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您的问题可能与 SQL Server 中的 unicode 字符串有关。这可能会有所帮助
http://support.microsoft.com/kb/239530
更新:我的错误,我没有正确阅读问题,我以为我们在谈论 SQL Server。阅读 SQL Lite 文档,http://www.sqlite.org/faq.html#q18
I think your problem might be related to unicode string in SQL Server. This might help
http://support.microsoft.com/kb/239530
UPDATE: My mistake, I did not read the question correctly, I thought we were talking about SQL Server. Reading the SQL Lite documentation, http://www.sqlite.org/faq.html#q18
这是解决方案:
不要使用 C# 函数comboBoxCitySearch.Text.ToLower();只是在 SQL 中使用:
Here is solution:
Dont use C# function comboBoxCitySearch.Text.ToLower(); Just in SQL use: