user221074 user221074 - 3 months ago 16
C# Question

Get cell value from Dataset

I have Table in Data Set and when i try get cell value if value is null i get exception. Strong Typing Exception
"The value for column Surname in table AI_PARTNERS is Db Null."
Ever time when i try turn


if is null i get exception and can't do compare with null.

_partnerInfo.Surname = partnersDataSet.AI_PARTNERS[0].SURNAME

how get the value or empty string if value null?


You can always use one of the DataRow.IsNull method overloads. Also, since you are using typed data set, there must be a generated method called IsSURNAMENull().

But you can get that automatically. Open the typed dataset xsd file in the designer, select the SURNAME property, go to Properties window and change the NullValue property from (Throw exception) (the default) to either (Null) or (Empty).

Reference: Annotating Typed DataSets