Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# SQL Data Adapter System.Data.StrongTypingException

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?

like image 325
René Stalder Avatar asked Apr 23 '10 08:04

René Stalder


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

What is C full form?

Full form of C is “COMPILE”.

Why is C named so?

Because a and b and c , so it's name is C. C came out of Ken Thompson's Unix project at AT&T. He originally wrote Unix in assembly language. He wrote a language in assembly called B that ran on Unix, and was a subset of an existing language called BCPL.


1 Answers

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

like image 97
Julian de Wit Avatar answered Sep 20 '22 15:09

Julian de Wit