函数在 Table 适配器查询生成器中不起作用
Functions not working in Table Adapter Query bulider
我正在使用 Visual Studio 2013,我尝试在 Table 适配器查询生成器(在 DataSet.XSD 中)中使用一些函数(如 "cast" 和 Year )。我每次都会收到错误消息。我 运行 在其他 sql 程序上的 sql 语句并且它工作正常。有人遇到过这个问题吗?
SQLite 没有这个功能YEAR(...)
。请尝试 strftime('%Y', degrees.ExamDate) = '2017'
。
你的数据源是SQL服务器还是SQLite。如果您使用的是 SqLite,则不允许使用 Year()、Cast() 等函数。
如果您使用的是 SQLite,请在下面找到 link 日期时间函数参考,
https://www.sqlite.org/lang_datefunc.html
如你所求的Cast函数,有SO post描述了cast函数,与SQLServer
类似
SQLite supports CAST and:
Casting an INTEGER or REAL value into TEXT renders the value as if via sqlite3_snprintf() except that the resulting TEXT uses the
encoding of the database connection.
So you can do things like this:
select cast(some_integer_column as text) from some_table;
Or, depending on what you're trying to do, you could just treat the
numbers as strings and let SQLite coerce the types as it sees fit:
select some_int || ' pancakes' from some_table; select some_int || ''
from some_table;
我正在使用 Visual Studio 2013,我尝试在 Table 适配器查询生成器(在 DataSet.XSD 中)中使用一些函数(如 "cast" 和 Year )。我每次都会收到错误消息。我 运行 在其他 sql 程序上的 sql 语句并且它工作正常。有人遇到过这个问题吗?
SQLite 没有这个功能YEAR(...)
。请尝试 strftime('%Y', degrees.ExamDate) = '2017'
。
你的数据源是SQL服务器还是SQLite。如果您使用的是 SqLite,则不允许使用 Year()、Cast() 等函数。
如果您使用的是 SQLite,请在下面找到 link 日期时间函数参考,
https://www.sqlite.org/lang_datefunc.html
如你所求的Cast函数,有SO post描述了cast函数,与SQLServer
类似SQLite supports CAST and:
Casting an INTEGER or REAL value into TEXT renders the value as if via sqlite3_snprintf() except that the resulting TEXT uses the
encoding of the database connection.
So you can do things like this:
select cast(some_integer_column as text) from some_table;
Or, depending on what you're trying to do, you could just treat the numbers as strings and let SQLite coerce the types as it sees fit:
select some_int || ' pancakes' from some_table; select some_int || '' from some_table;