'<costantenull>' non è dichiarato

Aggiornamento: novembre 2007

Messaggio di errore

'<costantenull>' non è dichiarato. La costante Null non è più supportata. Utilizzare System.DBNull.
'<nullconstant>' is not declared. Null constant is no longer supported; use System.DBNull instead.

Un'istruzione utilizza la parola chiave Null, che non è più supportata in Visual Basic.

ID errore: BC30822

Per correggere l'errore

  1. Utilizzare DBNull invece di Null. Nell'esempio che segue viene illustrato quanto descritto.

    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. Utilizzare la parola chiave Nothing (Visual Basic) per assegnazioni e confronti durante l'utilizzo di variabili oggetto. Nell'esempio che segue viene illustrato quanto descritto.

    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
    

Vedere anche

Concetti

Riepilogo delle modifiche al supporto degli elementi di programmazione

Riferimenti

DBNull

Nothing (Visual Basic)