﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Request for Primary Key Generation example</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 23 May 2026 03:52:23 GMT</lastBuildDate><ttl>20</ttl><item><title>Request for Primary Key Generation example</title><link>http://forum.strataframe.net/FindPost30763.aspx</link><description>&lt;font color="#000000" size="3" face="Times New Roman"&gt;&lt;/font&gt;&lt;span style='color: rgb(31, 80, 128); font-family: "Verdana","sans-serif"; font-size: 9pt;'&gt;Hi,&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color="#000000" size="3" face="Times New Roman"&gt;&lt;/font&gt;&lt;span style='color: rgb(31, 80, 128); font-family: "Verdana","sans-serif"; font-size: 9pt;'&gt;Iam working with the trial version of Strataframe and am attempting to get asimple VS 2008 C# CRUD proof of concept test application functioning for SybaseSQL Anywhere 11. I am almost there, navigation and edits work fine - but Ican't seem to discover the correct method for primary key generation tofacilitate a successful insert. The default behavior of the BO is expecting an autogenerated primary key Id which is not the methodology we are using. I am usinga key table with a simple key id field that is programmatically incrementedwith each new insert. I see properties in the BO on my form that seem toindicate that independent primary key generation is supported but I have notbeen able to find a closed loop example that shows/discusses the BO setup andform controls and related properties and possible custom procedures necessaryto implement this. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color="#000000" size="3" face="Times New Roman"&gt;&lt;/font&gt;&lt;span style='color: rgb(31, 80, 128); font-family: "Verdana","sans-serif"; font-size: 9pt;'&gt;Isthere an example, or a forum thread or something in the documentation that Ihave missed that covers this?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color="#000000" size="3" face="Times New Roman"&gt;&lt;/font&gt;&lt;span style='color: rgb(31, 80, 128); font-family: "Verdana","sans-serif"; font-size: 9pt;'&gt;Anyinformation would be helpful.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color="#000000" size="3" face="Times New Roman"&gt;&lt;/font&gt;&lt;span style='color: rgb(31, 80, 128); font-family: "Verdana","sans-serif"; font-size: 9pt;'&gt;Thanks,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color="#000000" size="3" face="Times New Roman"&gt;&lt;/font&gt;&lt;span style='color: rgb(31, 80, 128); font-family: "Verdana","sans-serif"; font-size: 9pt;'&gt;RorySawtelle&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color="#000000" size="3" face="Times New Roman"&gt;&lt;/font&gt;</description><pubDate>Mon, 02 Jan 2012 20:48:08 GMT</pubDate><dc:creator>Rory Sawtelle</dc:creator></item><item><title>RE: Request for Primary Key Generation example</title><link>http://forum.strataframe.net/FindPost30765.aspx</link><description>Hi Rory,&lt;br/&gt;&lt;br/&gt;[quote][b]Rory Sawtelle (1/2/2012)[/b][hr]&lt;span style="color: rgb(31, 80, 128); font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;"&gt;&lt;/span&gt;&lt;span style="color: rgb(31, 80, 128); font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;"&gt;Isthere an example, or a forum thread or something in the documentation that Ihave missed that covers this?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;[/quote]&lt;br/&gt;&lt;br/&gt;As you are guessing SF Business Object do support handling your own PK generation.&amp;nbsp; Basically to bypass default behavior simply set the BO properties PrimaryKeyIsAutoIncremented = False and PrimaryKeyIsUpdatable = True, if you are using a base BO class (which everybody should) then you can set this in the base class otherwise you can do it in the instance in your forms or via code.&lt;br/&gt;&lt;br/&gt;Also it is a good idea to look at all the properties of the BO, their descriptions and the help file to grasp all the control the developers have over how the BO should work for each application.&lt;br/&gt;&lt;br/&gt;Ger, thanks for the sample, I used to use that technique a while back when working with Visual FoxPro, now what I do is simply get the MAX(FieldName) + 1 for simpler process where not too many users will be working at the same time.</description><pubDate>Mon, 02 Jan 2012 20:48:08 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Request for Primary Key Generation example</title><link>http://forum.strataframe.net/FindPost30764.aspx</link><description>Hi Rory.&lt;br/&gt;&lt;br/&gt;When I need a simple Primary Key , I set the AutoIncrement in Sql Server and this works without having to do anything else. When I have a need for a Unique Key that must be unique but cannot be a standard 'PrimaryKey' I use a Special 'UniqueTable' tbale set up in the datatbase which has 3 columns:&lt;br/&gt;&lt;br/&gt;UNI_PK&amp;nbsp;&amp;nbsp; Unique key of the UNIQUE Table&lt;br/&gt;&lt;br/&gt;UNI_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp; A link to a unique Key I want to generate (e.g. INVNUM&amp;nbsp;&amp;nbsp; ORDERNUM&amp;nbsp;&amp;nbsp; DESPATCHNUM&amp;nbsp;&amp;nbsp; etc)&lt;br/&gt;&lt;br/&gt;UNI_PREVKEY&amp;nbsp;&amp;nbsp;&amp;nbsp; The Most recent Key that was used for UNI_NAME&lt;br/&gt;&lt;br/&gt;I then have a Method set up , which I call, and it returns the next available unique key&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;[quote]public static int GenerateUniqueKey(string myName)&lt;br/&gt;{&lt;br/&gt;MicroFour.StrataFrame.Business.BusinessLayer.TransactionBegin("", IsolationLevel.Serializable);&lt;br/&gt;UniBO bo = new UniBO();&lt;br/&gt;bo.UniFillByTable(myName);&lt;br/&gt;if (bo.Count == 0)&lt;br/&gt;{&lt;br/&gt;bo.Add();&lt;br/&gt;bo.UNI_NAME = myName;&lt;br/&gt;bo.UNI_PREVKEY = 1;&lt;br/&gt;}&lt;br/&gt;else&lt;br/&gt;{&lt;br/&gt;bo.UNI_PREVKEY = bo.UNI_PREVKEY + 1;&lt;br/&gt;}&lt;br/&gt;bo.Save(true);&lt;br/&gt;MicroFour.StrataFrame.Business.BusinessLayer.TransactionCommit("");&lt;br/&gt;return bo.UNI_PREVKEY;&lt;br/&gt;} // GenerateUniqueKey (Cannot have more than one Identity Key in SqlServer[/quote]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;&lt;/font&gt;&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;There are probabaly other ways of doing this also, but this is what I have settled on&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;Regards,&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;Gerard&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;&lt;/font&gt;&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;/font&gt;&lt;/font&gt;</description><pubDate>Mon, 02 Jan 2012 16:44:48 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item></channel></rss>