No se declaró '<nullconstant>'

No se declaró '<nullconstant>'. Ya no se admite la constante 'Null' de la base de datos; use System.DBNull en su lugar.

Una instrucción usa la palabra clave Null , que ya no se admite en Visual Basic.

Identificador de error: BC30822

Para corregir este error

  1. Use DBNull en lugar de Null. En el siguiente ejemplo se muestra cómo hacerlo.

    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 la palabra clave Nothing en las asignaciones y comparaciones al usar variables de objeto. En el siguiente ejemplo se muestra cómo hacerlo.

    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  
    

Consulte también