docs icon indicating copy to clipboard operation
docs copied to clipboard

DBNull exception /example/

Open LisandroSu opened this issue 8 years ago • 3 comments

@warchlak commented on Sun Sep 02 2018

Null value from database (mdb in my scenario) is DBNull. So i got dbnull exception when cell data is empty. To avoid this, line If (Me.Value Is Nothing) Then should be changed to If (Me.Value Is Nothing Or IsDBNull(Me.Value)) Then

Public Class CalendarCell
  Inherits DataGridViewTextBoxCell

  Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer,
      ByVal initialFormattedValue As Object,
      ByVal dataGridViewCellStyle As DataGridViewCellStyle)

    ' Set the value of the editing control to the current cell value.
    MyBase.InitializeEditingControl(rowIndex, initialFormattedValue,
        dataGridViewCellStyle)

    Dim ctl As CalendarEditingControl =
        CType(DataGridView.EditingControl, CalendarEditingControl)

    ' Use the default row value when Value property is null.
    If (Me.Value Is Nothing Or IsDBNull(Me.Value)) Then

Szczegóły dokumentu

⚠ Nie edytuj tej sekcji. Jest ona wymagana dla docs.microsoft.com ➟ Dołączanie problemu w usłudze GitHub.

LisandroSu avatar Sep 03 '18 17:09 LisandroSu

Hi team,

Can you check this issue?

Thanks!

LisandroSu avatar Sep 03 '18 17:09 LisandroSu

Just for clarification. Example by itself isn't operationg on database file and exception is not caused.

warchlak avatar Sep 03 '18 17:09 warchlak

This issue has been closed as part of the issue backlog grooming process outlined in #22351.

That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the @dotnet/docs team for visibility.

dotnet-bot avatar Jan 25 '21 14:01 dotnet-bot