AddNew, DataBinding and more

  • Thread starter Thread starter Chistof Goldberg
  • Start date Start date
C

Chistof Goldberg

Hello folks out there,

I am new to ADO.NET working with C#.

I have a table with some restrictions (Not allowing Null values) on some
fields. When I add a new record to the BMB it's not reflected to my data set
which is
a member variable to the form. So I tried to merge the value to the data set
calling
EndCurrentEdit or UpdateDataSet subsequently getting an exception ("does not
allow null . . .")

Is there a way to move this new row from the BindingManagerBase to the data
set without
saving the new row to the database so I can work on that data. I want to do
validation on my
own and dertermine when the data is written to the database.

Any help appreciated. Thanks.

- Christof
 
Hi Chistof,

Chistof Goldberg said:
Hello folks out there,

I am new to ADO.NET working with C#.

I have a table with some restrictions (Not allowing Null values) on some
fields. When I add a new record to the BMB it's not reflected to my data set
which is
a member variable to the form. So I tried to merge the value to the data set
calling
EndCurrentEdit or UpdateDataSet subsequently getting an exception ("does not
allow null . . .")

Is there a way to move this new row from the BindingManagerBase to the data
set without
saving the new row to the database so I can work on that data. I want to do
validation on my
own and dertermine when the data is written to the database.

The error you are getting is the consequence of dataset (datatable)
settings - at least on DataColumn has AllowNulls = false..
It has nothing to do with database.
If you allow nulls at datatable you can store the record in it and process
it as you wish before storing it do database.
 
Hi Miha,

thanks for your answer, you are quite right.
The DataSet is ( I guess) initialized with the DB
Values for allowing DBNulls. Setting
DataSet.Tables[...].Columns[...].AllowDBNull = true
allows me to validate the values on my own.
That works fine for me. But when not evaluating the
values, I will get an error from the Database. That's ok.

- Christof
 
Back
Top