DBNull exception /example/
@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.
- ID: 936cb607-644a-bb4e-d18e-a421fc2c691b
- Version Independent ID: 02f9571e-8891-4c46-ee18-6c39c3a25850
- Content: Porady: kontrolki hosta w komórkach DataGridView formularzy systemu Windows
- Content Source: docs/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells.md
- GitHub Login: @dotnet-bot
- Microsoft Alias: dotnetcontent
Hi team,
Can you check this issue?
Thanks!
Just for clarification. Example by itself isn't operationg on database file and exception is not caused.
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.