我在Plant表SeedStartMonths中有一个字段作为nvarchar,包含1 2 4 11.我正在尝试SELECT * FROM Plant WHERE CONTAINS(SeedStartMonths,'11')并且它给了我错误。
string tmp = ( (int) thisMonth ).ToString();
using (SqlCeCommand com = new SqlCeCommand("SELECT * FROM Plant WHERE CONTAINS(SeedStartMonths, '" + tmp + "')", con))
{
SqlCeDataReader reader = com.ExecuteReader();
while (reader.Read())
{
try
{
AddReaderToGardenEntityList(gardenEntities, reader);
}
catch (Exception)
{
//unable to parse datas
}
}
}
答案 0 :(得分:0)
SQL-CE不支持CONTAINS
谓词函数。但它确实支持LIKE
运算符,您必须像这样重写查询:
SELECT * FROM Plant WHERE SeedStartMonths LIKE '%11%'