StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Primary Key GUID for ReplicationExpand / Collapse
Author
Message
Posted 10/13/2006 2:33:23 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 2:01:30 PM
Posts: 372, Visits: 2,492
A few months ago I was playing around with a few different scenarios for upgrading a fox 2.6 payroll app to .Net/Sql.

Basically we have a number of branch office's that will be running the application using a local data source. It is important that this data source be local as we cannot afford the possibility of downtime due to internet connectivity as well as possible latency issues etc.

The idea was to design the data so that it would replicate to a centralized DB as well as replicate back to the individual offices using a PK guid field and having an officeid field to indicate the office that generated the data.

So branch A would replicate to main server and then back to branch B and vice versa thus all branches would have a "full" set of data that would then be filtered by the officeid field in the data so they would only be "looking" at their data. 

The problem was with trying to update a record with the guid PK. It would throw an exception and bomb out. I remember talking with Ben about this and do not remember what the outcome was. Due to another project I had to put this on hold and am just starting to get back into thinking about design issues.  I was wondering if this has been resolved since then or if you guys have any other suggestions on how to handle this type of scenario.

Thanks

PAul 

Post #3583
Posted 10/13/2006 4:14:58 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/09/2008 3:36:08 PM
Posts: 2,686, Visits: 1,891
Yes, you can do the Guid PKs now.  You can do them one of two ways... tell the business object that the PrimaryKeyIsAutoIncremented = False and set the primary key within the SetDefaultValues() event handler to Guid.NewGuid() or you can set the PrimaryKeyIsAutoIncremented = True and use stored procedures with an output parameter as the new GUID that was assigned.  Like this:

CREATE PROCEDURE MyTableInsert
   @pk UniqueIdentifier OUTPUT,
   @field1 VarChar(50)
AS
   SELECT @pk = NEWID()
   INSERT INTO MyTable (pk, field1) VALUES (@pk, @field1)

You have to manually assign the GUID since if you just put NEWID() in as the default value of the column, there's no way to get it back out.

As for the ROWGUID field that is used for replication, if it is also the primary key, then you're done, but if it's a separate column, then you'll want to set the field in the SetDefaultValues() event handler to DbNull.Value so that the server can assign it; you won't have to worry about retrieving since it's only used for replication.


www.bungie.net
Post #3591
Posted 10/16/2006 9:19:52 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 2:01:30 PM
Posts: 372, Visits: 2,492
Thanks for the answer Ben. I will try to test it out sometime this week and you will be the first to know if I have any issues.

Paul

Post #3623
Posted 10/16/2006 10:17:45 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/09/2008 3:36:08 PM
Posts: 2,686, Visits: 1,891
Just keep me posted.  Thanks


www.bungie.net
Post #3626
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 7:37pm

Powered by InstantForum.NET v4.1.4 © 2009
Execution: 0.125. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.