我正在查询一个datagridview,它工作得很好,除非其中一个单元格没有任何内容(dbnull)。如何克服这一点?
异常:没有为类型'DBNull‘和类型'DBNull’定义运算符'=‘。
Dim query = From row As DataGridViewRow In DataGridView1.Rows _
Where row.Cells(SelectedColumnIndex).Value = filter _
And row.Visible = False _
Select row Distinct发布于 2011-04-29 22:53:19
使用.Equals()方法比较其中可能为null的值。示例:
Dim query = From row As DataGridViewRow In DataGridView1.Rows _
Where row.Cells(SelectedColumnIndex).Value.Equals(filter) _
And !(row.Visible) _
Select row Distinct或者,如果两者都为空,则可以使用基本Object.Equals()方法进行比较:
Dim query = From row As DataGridViewRow In DataGridView1.Rows _
Where Object.Equals(row.Cells(SelectedColumnIndex).Value, filter) _
And !(row.Visible) _
Select row Distincthttps://stackoverflow.com/questions/5833591
复制相似问题