SuspendBinding/ResumeBinding

C

Christian Ista

Hello,

I have a form where the controls are linked to a Access database via Dataset
Adapter and DataSet. I can navigate in the dataset.

Now I'd like to use the same form to insert data.

For that, my idea is :
- SuspendBinding
- Clear TextBox
- User fill in the Textbox
- Insert in DataRow and after in Database
- ResumeBinding

But I have a problem, when I do this (see below)

I receive this error message (exception raised):
System.Windows.Forms
DataBinding could not find a row in the list that is suitable for all
bindings.

An idea ?

Thanks,

Christian,

The code, in the event button (ADD) click :
try
{
BindingManagerBase binMng=BindingContext [dsMyMovie, "MOVIE"];
binMng.SuspendBinding();
}
catch(Exception ex)
{
MessageBox.Show(ex.Source);
MessageBox.Show(ex.Message);
}
 
M

Miha Markic

Hi Christian,

Didn't you overcomplicated a bit?

You should invoke BindingManagerBase.AddNew() method.
When you are finished editing you should call
BindingManagerBase.EndCurrentEdit().
There you have a DataRow in DataTable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top