Null problem

  • Thread starter Thread starter aculfa
  • Start date Start date
A

aculfa

We've a typed dataset which has a number of datatables.

After some computing we insert rows to these datatables.

My question is, we want to insert null value to an integer column in this
datatable. How can this be done?

What should we do to do sth. like below;

myTypedDataSet.myDataTable.addmyDataTableRow(strValue1,
intValue2,
intValue3,
null, /*this column is an integer column*/
intValue5);

Thanks,
 
Hi,

Ah, yes, silly isn't it.
I would create a NewMyDataTableRow first and set its properties. Only then I
would add it to table.
 
Preparing the row is not the problem..

The problem is, DataTable doesn't allow such an insertion. What should be
done to insert null to datatable.

We can easily do this when inserting to database..
 
It's already like that, but I can not insert due to int datatype
restriction..

I found a nullableInt class, set my values to instances of this class. But
when inserting , this should also be converted to int (because of typed
dataset) and trying to convert null to int results in Zero or Error..
 
Hi,

I want to say how the problem solved..

foreach(DataColumn dc in myTypedDataSet.Tables[0].Columns
{
dc.AllowDbNull = true; /* you should set this property to
"true" */
}

Then you can insert null to columns of any type..

Without this trying to insert "null" to an integer column ends up failure...

Happy Weekend,
 
Back
Top