需要从Sql Case访问True或False

时间:2017-05-05 08:35:54

标签: c# asp.net

在Sql Case方法中我声明了真或假条件,但我需要将true或false设计​​为图标(正确/错误的图标)。 1.Bellow我附上了我的.netC#code

 char c = 'A';
    int Role = 1, Value;
    string RoleMenu = "";
    this.str_RoleKey = ds.Tables[0].Rows[0]["RoleKey"].ToString();
    foreach (DataRow dr in ds.Tables[0].Rows)   
    {
        if (dr["RoleKey"].ToString() != "")
        {
            this.str_Case += " ,case when " + c + ".MenuKey is null then 'false' else 'true' end '" + Role + "' ";
            this.str_Join += " left outer join (select * from MenuRole where RoleKey='" + this.str_RoleKey + "') " + c + " on Me.MenuKey = " + c + ".MenuKey ";

            RoleMenu += "<td>%%"+ Role +"%%</td>";
            c++;
            Role++;
        }

    }

    RoleMenu = "<td>%%MenuName%%</td>" + RoleMenu;

    string str_sql1 = " select Me.MenuKey,Me.MenuName "
        + this.str_Case
        + " from Menu Me"
        + this.str_Join;

1 个答案:

答案 0 :(得分:0)

而不是从您的SQL返回varchar(&#39; true&#39;或&#39; false&#39;),而不是返回bit,其中1为真,0是假的。