62,268
社区成员
发帖
与我相关
我的任务
分享if (condition)
string str = "select colA,colB,colC from tableA where colA='xxx' and colD in (@role)"; string str = "select colA,colB,colC from tableA where colA='xxx'";
if (condition)
str += " and colD in ('a','b')";
//SqlParameter[] param = {
// new SqlParameter ("@role",SqlDbType.NVarChar,300)};
//param[0].Value = "'a','b'";
SqlDataReader dr = SQLUtility.ExecuteReader(SQLUtility.ConnMenu, CommandType.Text, str, parm);
List<RDTreeNode> treeNode = new List<RDTreeNode>();
while (dr.Read())
{
... ...
SqlCommand command = new SqlCommand();
string str = "select colA,colB,colC from tableA ";
if (condition)
{
str += "where colD in (@role)";
SqlParameter param = new SqlParameter ("@role",SqlDbType.NVarChar,300);
command.Parameters.Add(param).Value = "'a','b'";
}
command.CommandText = str;