W
Wladek
Hi,
I have three Access tables: tblInvestor, tblProject and
tblInvestorProject. It is a many to many relation between
tblProject and tblInvestor.
The tables look something like this:
tblInvestor tblProject tblInvestorProject
----------- ------------ ------------------
IDInvestor (PK) IDProject (PK) IDInvestor (PK)
Name Title IDProject (PK)
InvestorType
I have two buttons: LoadData and SaveData, which
appropriately loads data from database and saves changes
back to database.
I have a combo on my form (cmbInvestor) which allows me
to select investor for a given project. The chosen
investor ID
(IDInvestor) should be written into tblInvestorProject.
The problem I have is that when I select investor from
cmbInvestor,
the appropriate data (IDInvestor) is written into dataset
but when
I read the DataViewRowState of the given row from
tblInvestorProject
it is Unchanged. Therefore I can't update the database.
Here is the code snippet:
// cmbInvestor
cmbInvestor.DataBindings.Add(new
System.Windows.Forms.Binding(
"SelectedValue",
dsTest1, "tlbInvestorProject.IDInvestor"));
cmbInvestor.DataSource = dsTest1.tblInvestor;
cmbInvestor.DisplayMember = "Name";
cmbInvestor.ValueMember = "IDInvestor";
....
private void btnLoadData_Click(object sender,
System.EventArgs e)
{
daInvestor.Fill(dsTest1);
daInvestorProject.Fill(dsTest1);
}
private void btnSaveData_Click(object sender,
System.EventArgs e)
{
// to do: try / catch
daInvestor.Update(dsTest1);
daInvestorProject.Update(dsTest1);
dsTest1.AcceptChanges();
}
This method works when I have one to many relationship
but when I have
many to many relationship the rowstate is unchanged when
I use the
combobox.
On the other hand if I use DataGrid for
tblInvestorProject, updates work.
Does anybody have any idea what could be the cause? I
have tried using
EndCurrentEdit but without effect. Maybe I'm doing
something wrong?
I have three Access tables: tblInvestor, tblProject and
tblInvestorProject. It is a many to many relation between
tblProject and tblInvestor.
The tables look something like this:
tblInvestor tblProject tblInvestorProject
----------- ------------ ------------------
IDInvestor (PK) IDProject (PK) IDInvestor (PK)
Name Title IDProject (PK)
InvestorType
I have two buttons: LoadData and SaveData, which
appropriately loads data from database and saves changes
back to database.
I have a combo on my form (cmbInvestor) which allows me
to select investor for a given project. The chosen
investor ID
(IDInvestor) should be written into tblInvestorProject.
The problem I have is that when I select investor from
cmbInvestor,
the appropriate data (IDInvestor) is written into dataset
but when
I read the DataViewRowState of the given row from
tblInvestorProject
it is Unchanged. Therefore I can't update the database.
Here is the code snippet:
// cmbInvestor
cmbInvestor.DataBindings.Add(new
System.Windows.Forms.Binding(
"SelectedValue",
dsTest1, "tlbInvestorProject.IDInvestor"));
cmbInvestor.DataSource = dsTest1.tblInvestor;
cmbInvestor.DisplayMember = "Name";
cmbInvestor.ValueMember = "IDInvestor";
....
private void btnLoadData_Click(object sender,
System.EventArgs e)
{
daInvestor.Fill(dsTest1);
daInvestorProject.Fill(dsTest1);
}
private void btnSaveData_Click(object sender,
System.EventArgs e)
{
// to do: try / catch
daInvestor.Update(dsTest1);
daInvestorProject.Update(dsTest1);
dsTest1.AcceptChanges();
}
This method works when I have one to many relationship
but when I have
many to many relationship the rowstate is unchanged when
I use the
combobox.
On the other hand if I use DataGrid for
tblInvestorProject, updates work.
Does anybody have any idea what could be the cause? I
have tried using
EndCurrentEdit but without effect. Maybe I'm doing
something wrong?