View Single Post
  #1 (permalink)  
Old September 21st, 2005, 06:21 AM
oricalchis oricalchis is offline
Registered User
 
Join Date: Sep 2005
Location: Bucharest, , Romania.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataAdapter.Update acts strangely

Hi everyone.

I'm having a bit of a problem with the DataAdapter.Update method... I have a DataSet in which i modify some records but when i call the update method i get the DBConcurrencyException which says that there was nothing to modify (0 records affected by the update).
This is strange because i have verified that prior to calling the update method some records WERE modified and the correspondant rows had the RowState propery set to 'Modified'.

What could be the problem?
Thanks in advance.

Here are some details about how my program is actually working:

- i have a mainform (called MainForm) in which i added the connection to the database (it's a Access database with a single Table called Conturi), a dataadapter called DA_Conturi and a typed dataset (the class is called OPDataSet and the variable DS_Main)

- the table is DS_Main.Conturi and is also typed (OPDataSet.ConturiDataTable)

- i then have another form (a navigator) called ConturiNav to which i pass the table. the user accesses this form by a menu item in the MainForm called MI_Conturi

Here are the constructors for the two classes and the MI_Conturi_Click method which handles the click event on the menu item:

[MainForm.cs]
...
private System.Data.OleDb.OleDbDataAdapter DA_Conturi;
private OPDataSet DS_Main;
public MainForm()
{
    InitializeComponent();
    Conturi.Fill(DS_Main.Conturi);
}
...
private void MI_Conturi_Click(object sender, System.EventArgs e)
{
    ConturiNav cn=new ConturiNav(DS_Main.Conturi);
    cn.ShowDialog();
    cn.Dispose();
    DA_Conturi.Update(DS_Main.Conturi);
}

[ConturiNav.cs]
public OPDataSet.ConturiDataTable conturi;
public DataView dataview;
...
public ConturiNav(OPDataSet.ConturiDataTable conturi)
{
    InitializeComponent();
    this.conturi=conturi;
    dataview=new DataView(this.conturi);
    SometextBox.DataBindings.Add(new
          Binding("Text",dataview,"Somefield"));
        ...
}

the error appears when the users edits the text in 'Sometextbox' and then closes the ConturiNav form.


Reply With Quote