所以我有一个名为 arr 的 ArrayList,其中包含诸如“decoration”、“metal”、“paper”等字符串。
我想要做的是循环遍历该 ArrayList,将每个标签添加到查询字符串中,使用该查询字符串从数据库中获取数据。目前我有这样的事情:
String strSel="select * from Table1 where Tags";
for(int x=0;x<arr.Count;x++){
if (x == arr.Count - 1)
{
strSel += " like '%'"+arr[x]+"'%'";
}
else
{
strSel += " like '%'" + arr[x] + "'%' or Tags";
}
}
cmdSel=new SqlCommand(strSel,connectionName);
sqlDataReaderName=cmdSel.ExecuteReader();
无论如何,我收到一个关于“bla 附近语法不正确”的错误......它可能与单引号或通配符有关,但我无法弄清楚。我究竟做错了什么?