﻿<?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?)  » increment pk for new vfp row</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 09:34:59 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: increment pk for new vfp row</title><link>http://forum.strataframe.net/FindPost11208.aspx</link><description>Hehe, yep (typename) is the correct cast.&amp;nbsp; Glad you got it working :)&amp;nbsp; And technically when you go from an object to a value type, you're "unboxing" ;)&amp;nbsp; Wrapping a value in an object reference is "boxing."</description><pubDate>Wed, 29 Aug 2007 10:21:50 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>increment pk for new vfp row</title><link>http://forum.strataframe.net/FindPost11134.aspx</link><description>I have a SF winform bound to one of my BO's that sits on top of a vfp oledb table. When I try to save a new row I get this:&lt;br&gt;
&lt;br&gt;
BusinessLayerException&lt;br&gt;
  An error occurred while saving an the data to the server.&lt;br&gt;
DataLayerSavingException&lt;br&gt;
  Field ORDERID does not accept null values.&lt;br&gt;
OleDbException&lt;br&gt;
  Field ORDERID does not accept null values.&lt;br&gt;
&lt;br&gt;
Source     : MicroFour StrataFrame Business&lt;br&gt;
&lt;br&gt;
Stack Trace: &lt;br&gt;
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object&amp; executeResult)&lt;br&gt;
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&amp; executeResult)&lt;br&gt;
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object&amp; executeResult)&lt;br&gt;
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)&lt;br&gt;
   at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()&lt;br&gt;
   at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteNonQuery(DbCommand Command, Boolean IsTransactional, String TransactionKey)&lt;br&gt;
   at MicroFour.StrataFrame.Data.VfpDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)&lt;br&gt;
   at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)&lt;br&gt;
   at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)&lt;br&gt;
   at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)&lt;br&gt;
   at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)&lt;br&gt;
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)&lt;br&gt;
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()&lt;br&gt;
   at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e)&lt;br&gt;
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)&lt;br&gt;
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)&lt;br&gt;
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)&lt;br&gt;
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)&lt;br&gt;
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)&lt;br&gt;
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)&lt;br&gt;
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)&lt;br&gt;
   at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)&lt;br&gt;
   at System.Windows.Forms.Control.WndProc(Message&amp; m)&lt;br&gt;
   at System.Windows.Forms.ScrollableControl.WndProc(Message&amp; m)&lt;br&gt;
   at System.Windows.Forms.ToolStrip.WndProc(Message&amp; m)&lt;br&gt;
   at System.Windows.Forms.Control.ControlNative&amp;#119;indow.OnMessage(Message&amp; m)&lt;br&gt;
   at System.Windows.Forms.Control.ControlNative&amp;#119;indow.WndProc(Message&amp; m)&lt;br&gt;
   at System.Windows.Forms.Native&amp;#119;indow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
In VFP apps we usually keep track of the "next" key to use inside a special table... how do you suggest managing table keys of vfp tables in SF?</description><pubDate>Wed, 29 Aug 2007 10:21:50 GMT</pubDate><dc:creator>Rafe Kemmis</dc:creator></item><item><title>RE: increment pk for new vfp row</title><link>http://forum.strataframe.net/FindPost11186.aspx</link><description>Okay, this is working now:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;System.Data.OleDb.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;OleDbParameter&lt;/FONT&gt;&lt;FONT size=2&gt; param = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; System.Data.OleDb.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;OleDbParameter&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tablename"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"orderheader"&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;decimal&lt;/FONT&gt;&lt;FONT size=2&gt; newid = (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;decimal&lt;/FONT&gt;&lt;FONT size=2&gt;)MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataBasics&lt;/FONT&gt;&lt;FONT size=2&gt;.DataSources[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;].ExecuteStoredProcedure(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"GetKey"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DbCommandExecutionType&lt;/FONT&gt;&lt;FONT size=2&gt;.ExecuteScalar, param);&lt;/P&gt;&lt;P&gt;orderBO1.orderid = newid;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Tue, 28 Aug 2007 14:12:31 GMT</pubDate><dc:creator>Rafe Kemmis</dc:creator></item><item><title>RE: increment pk for new vfp row</title><link>http://forum.strataframe.net/FindPost11184.aspx</link><description>*closer*&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;System.Data.OleDb.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;OleDbParameter&lt;/FONT&gt;&lt;FONT size=2&gt; param = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; System.Data.OleDb.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;OleDbParameter&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;&lt;P&gt;param.ParameterName = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tablename"&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;&lt;P&gt;param.Value = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"orderheader"&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;object &lt;/FONT&gt;&lt;FONT size=2&gt;x = &lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataBasics&lt;/FONT&gt;&lt;FONT size=2&gt;.DataSources[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;].ExecuteStoredProcedure(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"GetKey"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DbCommandExecutionType&lt;/FONT&gt;&lt;FONT size=2&gt;.ExecuteScalar, param);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;This may be a simple .net question... how do I "box" the object into an int? type-casting in front of the ExecuteStoredProcedure() call throws an exception...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;thanks in advance!&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Tue, 28 Aug 2007 13:55:59 GMT</pubDate><dc:creator>Rafe Kemmis</dc:creator></item><item><title>RE: increment pk for new vfp row</title><link>http://forum.strataframe.net/FindPost11182.aspx</link><description>Thanks for the tip. Well I am getting close. I have the stored procedure created and functioning, called GetKey and it takes one parameter which is the table name, and returns the key as an integer.&lt;/P&gt;&lt;P&gt;Now how to call it within SF?&lt;/P&gt;&lt;P&gt;inside my_SetDefaultValues() : &lt;/P&gt;&lt;P&gt;int newid = &lt;BR&gt;MicroFour.StrataFrame.Data.DataBasics.DataSources[""].ExecuteStoredProcedure("GetKey",DbCommandExecutionType.ExecuteScalar,***NOT SURE WHAT TO PUT HERE**);&lt;/P&gt;&lt;P&gt;myBO.orderid = newid;&lt;/P&gt;&lt;P&gt;&lt;BR&gt;Am I close?</description><pubDate>Tue, 28 Aug 2007 13:38:08 GMT</pubDate><dc:creator>Rafe Kemmis</dc:creator></item><item><title>RE: increment pk for new vfp row</title><link>http://forum.strataframe.net/FindPost11167.aspx</link><description>Yeah, we have a NextID table for our FoxPro, too.&amp;nbsp; You'll need to set the PrimaryKeyIsAutoIncremented property on the business object to False so that tells the business object that you're going to supply the primary key.&amp;nbsp; Then, create a stored procedure to retrieve and increment the value from the NextID table for the table you're trying to insert into.&amp;nbsp; Lastly, call that stored procedure in the SetDefaultValues() of your business object which will retrieve the PK and set it on the record when you call BusinessObject.NewRow() or BusinessObject.Add().</description><pubDate>Tue, 28 Aug 2007 10:19:38 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>