C# SQL Data Adapter System.Data.StrongTypingException
Asked Answered
B

1

9

I get my data from SQL to Dataset with Fill. It's just one table with two columns (CategoryId (int) and CategoryName (varchar)).

When I look at my dataset after fill method, CategoryId Columns seems to be correct. But in the CategoryName I have a System.Data.StrongTypingException.

What could that mean?

Any Ideas?

Barth answered 23/4, 2010 at 8:40 Comment(0)
C
13

When you get the value of a row/column in a typed dataset, by default it raises this exception when the value is DBNull. So

string x = Row.CategoryName;//Raises this exception when CategoryName is null.

You can correct this with the typed dataset designer.
Set the property "Nullvalue" of the CategroyName column to "(Empty)"

Contaminant answered 29/4, 2010 at 8:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.