使用給出的下面的代碼顯示一個錯誤。錯誤是:「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