I created a tabbed app that has over a dozen checkboxes on the second
tab. When I add a new record thru dataview, and click on the secodn
tab I get and error Object cannot be cast from other datatype DBNull.
Here is my code for creating my dataview:
try
{
da.Fill(ds);
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
dt = ds.Tables[0];
SqlCommandBuilder cb = new SqlCommandBuilder(da);
dv.Table = dt;
cm = (CurrencyManager)this.BindingContext[dv];
Then I set my bindings:
this.chkbOperationsRpt.DataBindings.Add("Checked", dv,
"OperationsReport");
this.chkbDrugTask.DataBindings.Add("Checked", dv, "DrugTaskForce");
this.chkbCADFire.DataBindings.Add("Checked", dv, "CADFire");
this.chkbNCIC.DataBindings.Add("Checked", dv, "E911NCIC");
Then I add new record:
try
{
dv.RowFilter = string.Empty;
cm.AddNew();
cm.Refresh();
cm.EndCurrentEdit();
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
I've got my database set where these fields do not allow nulls and the
default value is 0.
So where do I check to see if there are nulls or how can I fix this?
Thanks
Tom