P
PeterZ
Yo,
Got a checkbox which I databind at runtime to a numeric column. It works
fine but when I add a new record I get the error:
--------------------------------
An unhandled exception of type 'System.InvalidCastException' occurred in
mscorlib.dll
Additional information: Object cannot be cast from DBNull to other types.
--------------------------------
I'm databinding just after adding a new record, so the order of events is:
1. Add new record code:
private void AddRecord()
{
// daBuilding is my DataAdapter, dsBuilding is my DataSet.
daBuilding.FillSchema(dsBuilding, System.Data.SchemaType.Source,
"BUILDING");
this.BindingContext[dsBuilding, "BUILDING"].AddNew();
this.DataBindControls();
}
2. Databinding code:
private void DataBindControls()
{
// Check the global flag to see if we have already databound controls.
if (this.dataBound)
return;
Got a checkbox which I databind at runtime to a numeric column. It works
fine but when I add a new record I get the error:
--------------------------------
An unhandled exception of type 'System.InvalidCastException' occurred in
mscorlib.dll
Additional information: Object cannot be cast from DBNull to other types.
--------------------------------
I'm databinding just after adding a new record, so the order of events is:
1. Add new record code:
private void AddRecord()
{
// daBuilding is my DataAdapter, dsBuilding is my DataSet.
daBuilding.FillSchema(dsBuilding, System.Data.SchemaType.Source,
"BUILDING");
this.BindingContext[dsBuilding, "BUILDING"].AddNew();
this.DataBindControls();
}
2. Databinding code:
private void DataBindControls()
{
// Check the global flag to see if we have already databound controls.
if (this.dataBound)
return;