Conversion from type 'DBNull' to type 'String' is not valid

后端 未结 8 752
攒了一身酷
攒了一身酷 2020-12-09 16:06

i am receiving this problem

Conversion from type \'DBNull\' to type \'String\' is not valid.

Line 501: hfSupEmail.

8条回答
  •  臣服心动
    2020-12-09 16:43

    You can use the Field method of the Datarow combined with an If Operator to check for a Null value in one line like this. If it is null, you can replace it with an empty string (or another string of your choosing):

    hfSupEmail.Value = If(dt.Rows(0).Field(Of String)("SupEmail"), "")
    

提交回复
热议问题