﻿<?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 » Issues  » NewRow not creating Primary Key correctly</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 13:04:41 GMT</lastBuildDate><ttl>20</ttl><item><title>NewRow not creating Primary Key correctly</title><link>http://forum.strataframe.net/FindPost4973.aspx</link><description>I am executing the attached code on a BO and am experiencing a few issues.&amp;nbsp; &lt;/P&gt;&lt;P&gt;#1:&amp;nbsp; The primary key is being created as a -1 or -2 or something funny like that.&amp;nbsp; I have seen this before when you do a NewRow or an Add, but then it creates the proper key on the Save.&amp;nbsp; In this case it is not creating a new key and keeping the negative number.&amp;nbsp; &lt;/P&gt;&lt;P&gt;#2:&amp;nbsp; The new row is not showing up in the SQL query in query analyzer.&amp;nbsp; When I look at the CurrentDataTable after the Save operation it is showing up in there with the -2 PK, but when I run the query directly on the table it is not showing up at all.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Please let me know what I'm doing wrong here.&amp;nbsp; I do the Undo operation at the beginning because the BO is in Edit mode when it gets into this routine.&amp;nbsp; I am just trying to make a temp row that copies the current row and changes a couple of fields.&amp;nbsp; I also tried just doing the Add/Save operation and then an edit because I thought maybe when I copied the ItemArray it was overwriting the PK value somehow, but this still doesn't work.&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Public&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; AddTempRow()&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; Dim&lt;/FONT&gt;&lt;FONT size=2&gt; TempRow &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Object&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; TempKey &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&amp;nbsp; TempRow = CurrentRow.ItemArray&lt;BR&gt;&amp;nbsp; Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;Add()&lt;BR&gt;&amp;nbsp; Save()&lt;BR&gt;&amp;nbsp; Edit()&lt;BR&gt;&amp;nbsp; TempKey = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.ReportKey&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;CurrentRow.ItemArray = TempRow&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.ReportKey = TempKey&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.ReportDescr = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;""&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;Save()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Tue, 05 Dec 2006 13:59:24 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item></channel></rss>