未定义的函数调用lower() [英] Undefined function call lower()

查看:327
本文介绍了未定义的函数调用lower()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


表达式包含未定义的函数调用lower()


我在VS2012中有一个非常简单的SQLite类型化数据集。



我正在解析大量的数据,并希望在添加新行之前检查行是否已经存在。



我正在使用 .select( )方法返回一个数据行数组。如果数组的长度为零,我添加一个新的。简单!



所有的一切运行良好,但是如果情况错误,我已经添加了一个检查来防止添加重复的行。我正在存储文件名。



select语句是:

  lower(FileName)='+ EscapeFileName(strFileName).ToLower()+'

我在 lower(FileName)上收到上述错误。如果我删除这是正常工作,但显然检查是不可比较的。



该语句在SQLiteAdmin中按预期工作。

解决方案

如果我理解正确,你有一个.NET DataTable (查询的结果),你正在调用< a href =http://msdn.microsoft.com/en-us/library/det4aw50.aspx =nofollow> DataTable.Select(string) 传递一个where子句。



这个where子句由.NET处理,而不是由SQLite处理(由Tim指出)。您不能在DataTable的Select函数中使用SQLite(或任何其他DBMS)功能。您可以使用以下功能:



  • CONVERT - 将特定表达式转换为指定.NET框架类型

  • LEN - 获取字符串的长度

  • ISNULL 检查一个表达式,并返回所检查的表达式或替换值

  • IIF - 根据逻辑表达式的结果获取两个值之一

  • TRIM - 删除所有前导和尾随的空白字符,如\r,\\\
    ,\t,,'

  • SUBSTRING - 从字符串



中的指定点开始,获取指定长度的子字符串

有关详细信息,请参阅 DataView RowFilter语法[C#]


I am getting the following exception in my sqlite query:

The expression contains undefined function call lower()

I've got a very simple SQLite typed dataset in VS2012.

I'm parsing a large amount of data and want to check if a row already exists prior to adding a new row.

I'm using the .select() method to return an array of datarows. If the length of the array is zero I add a new new. Simple!

All has been working well, but I have added a check to prevent duplicate rows being added if the case is wrong. I am storing filenames.

The select statement is:

"lower(FileName) = '" + EscapeFileName(strFileName).ToLower() + "'"

However I get the above error on the lower(FileName). If I remove this is works fine, but obviously the check is not comparable.

The statement works as expected in SQLiteAdmin.

解决方案

If I understand correctly, you have a .NET DataTable (the result of a query) and you are calling DataTable.Select(string) passing in a where clause.

This where clause is processed by .NET, not by SQLite (as pointed out by Tim). You cannot use SQLite (or any other DBMS) function in the Select function for the DataTable. You can use these functions:

  • CONVERT – converts particular expression to a specified .NET Framework type
  • LEN – gets the length of a string
  • ISNULL – checks an expression and either returns the checked expression or a replacement value
  • IIF – gets one of two values depending on the result of a logical expression
  • TRIM – removes all leading and trailing blank characters like \r, \n, \t, ‚ ‘
  • SUBSTRING – gets a sub-string of a specified length, starting at a specified point in the string

See DataView RowFilter Syntax [C#] for more information.

这篇关于未定义的函数调用lower()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆