开发者

C# SQL Data Adapter System.Data.StrongTypingException

开发者 https://www.devze.com 2022-12-28 02:20 出处:网络
I get my data from SQL to Dataset with Fill. It\'s just one table with two columns (CategoryId (int) an开发者_如何学Cd CategoryName (varchar)).

I get my data from SQL to Dataset with Fill. It's just one table with two columns (CategoryId (int) an开发者_如何学Cd 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?


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)"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号