【发布时间】:2023-03-02 23:57:02
【问题描述】:
为什么会出现以下代码:
A = not IsDBNull(CurRow("BuyBook")) AndAlso CType(CurRow("BuyBook"), string) = "Yes"
导致以下错误:
Conversion from type 'DBNull' to type 'String' is not valid.
当 AndAlso 应该根据这篇文章短路时:
【问题讨论】:
-
你可以试试这个
A = (not IsDBNull(CurRow("BuyBook"))) AndAlso CType(CurRow("BuyBook"), string) = "Yes" -
调试代码以查看单元格内的数据。
-
我什至把它分成两个语句并尝试过。我认为 IsDBNull 坏了。
-
通过this 发帖。
-
顺便问一下,CurRow 是什么类型的? anIDataReader/SqlDataReader?
标签: asp.net .net vb.net sql-server-2008