Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Yes, it is possible to use a GUID as a primary key... I would recommend that you set the pk value within your SetDefaultValues event handler within the business object. Then, you can turn off the use of the stored procedures, and set the PrimaryKeyIsAutoIncremented property to False. However, if you want the server to assign the value, you'll need to set the "Default Value" of your field within the database to "(NEWID())", and leave the PrimaryKeyIsAutoIncremented = True so that the value will be retrieved.
If you want to assign the PK on the client side, the code would look like this:
VB:
Private Sub MyBO_SetDefaultValues()
'-- Set the pk value
Me.pkfield = Guid.NewGuid() '-- Creates a new, random GUID just like the NEWID() SQL method
End Sub
C#:
private void MyBO_SetDefaultValues()
{
//-- Set the pk value
this.pkfield = Guid.NewGuid(); //-- Creates a new, random GUID just like the NEWID() SQL method
}
|