使用给出的下面的代码显示一个错误。错误是:“Conversion from type 'DBNull' to type 'String' is not valid.
”帮我找到一个合适的解决方案。谢谢。从类型'DBNull'转换为类型'String'无效vb.net
代码:
cmd2.CommandText = "SELECT [first_name]+' ' +[middle_name]+' ' + [last_name] AS NAME, [staff_id] FROM [staff_profile]"
sdr2 = cmd2.ExecuteReader
While sdr2.Read
drop1l.Items.Add(New ListItem(sdr2("name"), sdr2("staff_id"))) // error popup here
End While
sdr2.Close()
看起来不错,有用的检查空。 +1我 – 2015-04-07 09:18:27