我试图使用水晶报告在我的数据网格视图上打印当前内容(它有一个过滤器或搜索选项)但是这个错误总是来自我的代码
cmd.CommandText = ("SELECT * FROM tbIngredients WHERE " +
stcMRP.Selected + " ORDER BY IngredientNo");
答案 0 :(得分:0)
您不能只在SQL查询中发送stcMRP.Selected。你必须像这样翻译它:
string strWhereExpression = "[database column name]=";
if (stcMRP.Selected) strWhereExpression += "1";
else strWhereExpression += "0";
cmd.CommandText = String.Format("SELECT * FROM tbIngredients WHERE {0} ORDER BY IngredientNo", strWhereExpression);