SqlConnection mySqlCon;
mySqlCon=new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SelectCommand="select a.Product_Class_ID,name=replicate('--',a.depth*2-2)+a.name,parentname=c.name from Product_Class a join f_id() b on a.Product_Class_ID=b.Product_Class_ID left join Product_Class c on a.parent=c.Product_Class_ID where a.isvalid=0 order by b.sid";
SqlCommand cmd = new SqlCommand(SelectCommand,mySqlCon);
cmd.Connection.Open();
我想实现的效果是当parentname的在数据库中的值为null时,则给parentname取值为无,有值则按数据库中的值

解决方案 »

  1.   

    在数据库里面使用ISNULL(c.name,'无')
      

  2.   

    替换一下就可以了
    public string turnToflag(string Flag)
    {
    switch(Flag)
    {
    case "0":
    return "<font color=red>未公开</font>";
    case "1":
    return "<font color=blue>公开</font>";
    default:
    return "<font color=red>状态错误</font>";
    }
    }供参考
      

  3.   

    替换一下就行了,这样调用:
    public string turnToflag(string Flag)
    {
    switch(Flag)
    {
    case "0":
    return "<font color=red>未公开</font>";
    case "1":
    return "<font color=blue>公开</font>";
    default:
    return "<font color=red>状态错误</font>";
    }
    }