【发布时间】:2013-01-10 18:36:45
【问题描述】:
foreach (string word in allTheseWords)
{
allTheseStringsWhereClause = allTheseStringsWhereClause +
" report=" +
word +
" AND ";
}
问题是在循环之后,SQL 子句末尾多了一个AND。
我该如何解决这个问题?
【问题讨论】:
-
不要通过连接字符串生成 SQL。它容易受到 SQL 注入的攻击。
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
是否需要编辑?