Re: Master/Detail Navigator issues
- From: "Ginny Caughey MVP" <ginny.caughey.online@xxxxxxxxxxxxxx>
- Date: Fri, 2 May 2008 05:54:52 -0400
Peter,
The behavior you're describing sounds like what you get when the wrong entry for the detail table is selected in the designer. You need to select the detail table listed under the master table along with the master columns rather than the free standing one. If this is what you did already, I'm not sure why it's working the way you describe.
Ginny
"Peter" <Peter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:4F00CC62-3D0A-45AD-A863-174C018DF5E2@xxxxxxxxxxxxxxxx
This is a desktop app. Binding to a dataset. Used Designer for all items.
The following is the code for the Navigator SaveItem, Add new and Load. The
SQLCE 3.5 database contains two tables: 1 - Master, 2 - Detail.
Master Table
MasterID <-Primary Key
MasterName
Detail Table
MasterID
DetailData1
DetailData2
DetailID < Primary Key
The FK_Master_Detail relates the MasterID (Master) to MasterID (Detail) with
a relation and foreign key constraint. Update Rule and Delete set to
Cascade. Accept/Reject to None.
This same exact setup was done using SQL Express and the identity values
were set correctly in the Detail table. The values appears to be correctly
in both datagrids except for them being negative numbers. But once I atempt
to save the In the SQLCE they were still -1, -2, etc.
I put two datagrids on the form. The first one was bound to the
MasterBindingSource. The second was bound to the
fKMasterDetailBindingSource. IF i attempt to refresh the data turning off
constraints and then refilling I get an error. In looking at the database
the only value that was correct was the master table. The detail table still
have -1, -2 , etc
Thanks for any help.
private void masterBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.masterBindingSource.EndEdit();
this.fKMasterDetailBindingSource.EndEdit();
try
{
this.tableAdapterManager.UpdateAll(this.masterDetailCEDataSet);
}
catch (Exception ex)
{
MessageBox.Show(this, "Error: " + ex.Message, "ERROR",
MessageBoxButtons.OK);
}
}
private void SQLCE_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'masterDetailCEDataSet.Master' table. You can move, or remove it, as needed.
this.masterTableAdapter.Fill(this.masterDetailCEDataSet.Master);
// TODO: This line of code loads data into the
'masterDetailCEDataSet.Detail' table. You can move, or remove it, as needed.
this.detailTableAdapter.Fill(this.masterDetailCEDataSet.Detail);
}
private void fKMasterDetailBindingSource_AddingNew(object sender,
AddingNewEventArgs e)
{
this.masterBindingSource.EndEdit();
}
"Ginny Caughey MVP" wrote:
Peter,
Is this a desktop or mobile device app? Are you using a DataSet as your
binding source or something else like multiple SqlCeResultSet objects? Did
you use the designer and drop data bound controls on your form?
Ginny
"Peter" <Peter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DDF85FD9-6832-4F8F-B4E7-9E3644E2A06F@xxxxxxxxxxxxxxxx
>I have spent many hours on this and have not found a way to have a
> Master/Detail or Parent/Child table work with the child having the > correct
> identity value passed. I built two tests projects one with SQLCE and > the
> other with SQL Express 2005. The SQL Express 2005 worked without a > flaw.
> The same code did not work with the SQLCE. Both projects used the
> Navigator
> and the correct databinding needed for Parent/Child relationships. Is > this
> a
> bug in SQLCE? Thanks for any feedback.
>
>
--
Ginny Caughey
Device Application Development MVP
www.wasteworks.com
Software for Waste Management
--
Ginny Caughey
Device Application Development MVP
www.wasteworks.com
Software for Waste Management
.
- References:
- Master/Detail Navigator issues
- From: Peter
- Re: Master/Detail Navigator issues
- From: Ginny Caughey MVP
- Re: Master/Detail Navigator issues
- From: Peter
- Master/Detail Navigator issues
- Prev by Date: Re: Master/Detail Navigator issues
- Next by Date: Re: ArgumentOutOfRangeException when using DataTable.WriteXML
- Previous by thread: Re: Master/Detail Navigator issues
- Next by thread: ArgumentOutOfRangeException when using DataTable.WriteXML
- Index(es):