How to add a record in DataTabe?

  • Thread starter Thread starter Vlatko
  • Start date Start date
V

Vlatko

I have table 'Table1' in dataset 'DataSet1'. In Table1 I have column 'Code'.
On the form I have TextBox which is binded to 'Table1.Code'. 'Code1' is a
not null column. How can I create new record and save data from the TextBox
which I've enter to the dataset? When I try
this.BindingContext[DataSet1,"Table1"].AddNew(); I got exception 'Column
Code does not allow null values'. Please help.

Thx.
 
Hi Vlatko,

I suspect that you are already entering a new record when you recieve the
error.
If you call AddNew when you are already editing or adding a record the
BindingManagerBase is trying to save into datatable the current record.
Is this what happens?
 
No. I didn't edit the record before calling AddNew()


Miha Markic said:
Hi Vlatko,

I suspect that you are already entering a new record when you recieve the
error.
If you call AddNew when you are already editing or adding a record the
BindingManagerBase is trying to save into datatable the current record.
Is this what happens?
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

Vlatko said:
I have table 'Table1' in dataset 'DataSet1'. In Table1 I have column 'Code'.
On the form I have TextBox which is binded to 'Table1.Code'. 'Code1' is a
not null column. How can I create new record and save data from the TextBox
which I've enter to the dataset? When I try
this.BindingContext[DataSet1,"Table1"].AddNew(); I got exception 'Column
Code does not allow null values'. Please help.

Thx.
 
Back
Top