Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
SQL
ce
clients
clustering
connect
datamining
datawarehouse
dts
fulltext
jdbcdriver
msde
mseq
newusers
notificationsvcs
odbc
olap
programming
replication
reportingsvcs
security
securitytools
server
setup
sqlxml.viewmapper
tools
xml
  
 
date: Thu, 1 May 2008 11:47:06 -0700,    group: microsoft.public.sqlserver.ce        back       


Master/Detail Navigator issues   
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.
date: Thu, 1 May 2008 11:47:06 -0700   author:   Peter

Re: Master/Detail Navigator issues   
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"  wrote in message 
news:DDF85FD9-6832-4F8F-B4E7-9E3644E2A06F@microsoft.com...
>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
date: Thu, 1 May 2008 15:28:52 -0400   author:   Ginny Caughey MVP

Re: Master/Detail Navigator issues   
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"  wrote in message 
> news:DDF85FD9-6832-4F8F-B4E7-9E3644E2A06F@microsoft.com...
> >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
> 
> 
>
date: Thu, 1 May 2008 18:31:00 -0700   author:   Peter

Re: Master/Detail Navigator issues   
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"  wrote in message 
news:4F00CC62-3D0A-45AD-A863-174C018DF5E2@microsoft.com...
> 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"  wrote in message
>> news:DDF85FD9-6832-4F8F-B4E7-9E3644E2A06F@microsoft.com...
>> >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
date: Fri, 2 May 2008 05:54:52 -0400   author:   Ginny Caughey MVP

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us