Why empty cell throws an error during SQL stored procedure execution

后端 未结 4 857
再見小時候
再見小時候 2021-01-28 01:50
SELECT
    CAST ([content_html] AS XML).query(\'/root/Physicians/specialty/a\') AS [Specialty1]
    , CAST ([content_html] AS XML).query(\'/root/Physicians/specialty2/a\         


        
4条回答
  •  春和景丽
    2021-01-28 02:38

    As Gerbenny stated to say in the comments. DBNull won't be picked up by String.IsNullOrEmpty. DBNull is handled differently. to put it in code terms.

    DBNull.Value != null
    

    So basically You need to check if an Item is DBNull before trying to display or preforming any actions on it.

    Essentially

        <%# Eval("Specialty1") != DBNull.Value ? Eval("Specialty1").ToString() : String.Empty + DisplayMultipleValues(Eval("Specialty2") != DBNull.Value ? Eval("Specialty2").ToString() : String.Empty)
     + etc... %>
    

提交回复
热议问题