V
V
v1z2011-03-17 01:56:51
C++ / C#
v1z, 2011-03-17 01:56:51

DataGridView doesn't want to display null?

VS 2010, a small WinForms project. I use sqlite3 as a database.
The usual dataGridView table on the form is filled with data from the database through the DataSource. If there are no null records in the database, everything works fine. If this suddenly appears, it throws a ConstraintException error and marks the field with an exclamation point in a red circle. Although the field in the table is marked as NULL, i.e. matches the structure well.
Line where the exception is thrown:

//orders - название таблицы
this.ordersTableAdapter.Fill(this.databaseDataSet.Orders);

If you write an exception handler, then you can just ignore it and that's it, but I think it's wrong to do so. How can I correctly get rid of this error so that null fields are displayed in the table?
I myself am only learning C #, most likely, the problem is solved elementarily. I tried to prescribe DefaultCellStyle.NullValue = "none", it did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dzuba, 2011-03-17
@v1z

and in the table (not in the database, but in the dataset designer in the studio) does the field in which DBNull happens have the AllowDBNull property set to true?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question