Udostępnij za pośrednictwem


'<nullconstant>' is not declared

'<nullconstant>' is not declared. Null constant is no longer supported; use System.DBNull instead.

A statement uses the Null keyword, which is no longer supported in Visual Basic.

Error ID: BC30822

To correct this error

  1. Use DBNull instead of Null. The following example demonstrates this.

    Sub TestDBNull()
        Dim t As DataTable
        ' Assume the DataGrid is bound to a DataTable.
        t = CType(DataGrid1.DataSource, DataTable)
        Dim r As DataRow
        r = t.Rows(datagrid1.CurrentCell.RowNumber)
        r.BeginEdit
        r(1) = System.DBNull.Value ' Assign DBNull to the record.
        r.EndEdit
        r.AcceptChanges
        If r.IsNull(1) Then
            MsgBox("")
        End If
    End Sub
    
  2. Use the Nothing (Visual Basic) keyword for assignments and comparisons when you use object variables. The following example demonstrates this.

    Sub TestNothing()
        Dim cls As Object
        ' cls is Nothing if it has not been assigned using the New keyword.
        If (cls Is Nothing) Then
            MsgBox("cls is Nothing")
        End If
        cls = Nothing ' Assign Nothing to the class variable cls.
    End Sub
    

See Also

Concepts

Programming Element Support Changes Summary

Reference

DBNull

Nothing (Visual Basic)