microsoft / referencesource

Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework
https://referencesource.microsoft.com/
MIT License
3.17k stars 1.27k forks source link

System.Data.DataRowExtensions.UnboxT`1.NullableField[TElem](Object value) #188

Closed dotnetspark closed 1 year ago

dotnetspark commented 1 year ago

I have a SQL table with a field as INT and allows NULL. For some reason while reading the data using var x = row.Field<int?>("field_name"), I'm seeing this error message System.Data.DataRowExtensions.UnboxT`1.NullableField[TElem](Object value). Any idea what could be causing this?

https://github.com/Microsoft/referencesource/blob/master/System.Data.DataSetExtensions/System/Data/DataRowExtensions.cs